Axios backed JavaScript client for api.ideal-postcodes.co.uk
@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.
- Configuration & Usage
- Quickstart
- Client Documentation
- In Depth Client Documentation
- npm Module
- GitHub Repository
- Install
- Instantiate and Use client
- Catch Errors
npm install @ideal-postcodes/core-axiosimport { Client } from "@ideal-postcodes/core-axios" const client = new Client({ api_key: "iddqd" });import { lookupPostcode } from "@ideal-postcodes/core-axios" const addresses = await lookupPostcode({ client, postcode: "SW1A2AA" });import { errors, lookupAddress } from "@ideal-postcodes/core-axios" try { await lookupAddress({ client, query: "10 downing street" }); } catch (error) { if (error instanceof errors.IdpcRequestFailedError) { // IdpcRequestFailedError indicates a 402 response code // Possibly the key balance has been depleted } }npm testMIT
