Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including @ideal-postcodes/core-axios with all npm packages installed. Try it out:

var coreAxios = require("@ideal-postcodes/core-axios")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@ideal-postcodes/core-axios v2.2.1

Axios based client for api.ideal-postcodes.co.uk

Ideal Postcodes Axios

Axios backed JavaScript client for api.ideal-postcodes.co.uk

CI codecov Dependency Status npm version install size Release

@ideal-postcodes/core-axios is the Axios backed client for api.ideal-postcodes.co.uk. Axios is a promise based HTTP client for the browser and node.js and so is ideal for:

  • Frameworks that utilise server side rendering (Angular, Next.js, React, etc)
  • Isomorphic code (runs on browser and server)

Our JavaScript client implements a common interface defined at @ideal-postcodes/core-interface.

High level client documentation can be found at core-interface.

In depth client documentation can be found at core-interface.ideal-postcodes.dev.

Links

Other JavaScript Clients

Documentation

Configuration & Usage

Install

npm install @ideal-postcodes/core-axios

Instantiate

const { Client } = require("@ideal-postcodes/core-axios");

// or, if applicable,
import { Client } from "@ideal-postcodes/core-axios"

const client = new Client({ api_key: "iddqd" });

Configuration options

Use

const addresses = await client.lookupPostcode({ postcode: "SW1A2AA" });

Catch Errors

const { IdpcRequestFailedError } = Client.errors;

try {
  await client.lookupAddress({ query: "10 downing street" });
} catch (error) {
  if (error instanceof IdpcRequestFailedError) {
    // IdpcRequestFailedError indicates a 402 response code
    // Possibly the key balance has been depleted
  }
}

Test

npm test

Licence

MIT

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free