Latest Threat ResearchGlassWorm Loader Hits Open VSX via Developer Account Compromise.Details
Socket
Book a DemoInstallSign in
Socket

@times-visuals/postcode-search

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@times-visuals/postcode-search

Postcode search UI element, with optional Postcodes.io integration

latest
npmnpm
Version
1.1.0
Version published
Maintainers
2
Created
Source

Postcode search UI element, with optional Postcodes.io integration

Installation

# Yarn
$ yarn add @times-visuals/postcode-search

# npm
$ npm add @times-visuals/postcode-search

Usage

Postcodes.io

The Postcodes.io provider returns a standard response for most UK postcodes. The structure of the response object can be found on their website, under the [GET] api.postcodes.io/postcodes/:postcode lookup.

import PostcodeSearch from "@times-visuals/postcode-search";

export default () => (
  <PostcodeSearch
    provider="postcodes.io"
    onLoad={response => {
      // `response` will be the value of the "result" property from the Postcodes.io API request
    }}
    onError={error => {
      // `error` is an instance of a JS Error
    }}
  />
);

Custom provider

You can choose to provide your own request handler, if you want to connect the UI element up to your own API.

import PostcodeSearch from "@times-visuals/postcode-search";

export default () => (
  <PostcodeSearch
    provider="custom"
    onRequest={input => Promise} // `input` is a string of the user's input, you must return a Promise with the response data
    onLoad={response => {
      // `response` will be the result of the Promise from your custom `onRequest` handler
    }}
    onError={error => {
      // `error` is an instance of a JS Error
    }}
  />
);

FAQs

Package last updated on 14 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts