Package Exports
- usps-webtools-promise
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (usps-webtools-promise) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
About:
This package was forked from MadisonReed/usps-webtools, but it has been modernized with Typescript and Promises (async/await). Note: This is a drop-in replacement for MadisonReed/usps-webtools, it produces the same output.
Installation:
npm install usps-webtools-promiseUsage:
Initializing the usps model with a user id.
Example:
const USPS = require('usps-webtools-promise').default;
// or
import USPS from "usps-webtools-promise";
const usps = new USPS({
// This can be created by going to https://www.usps.com/business/web-tools-apis/ and registering for an id
userId: 'USPS User id',
// USPS returns ALL CAPS, this boolean turns on Proper Caps for both Street lines and City. This is an optional item.
properCase: boolean
});verify(object)
Verify takes one parameter: object
object: street1, street2, city, state, zip
Example
usps.verify({
street1: '322 3rd st.',
street2: 'Apt 2',
city: 'San Francisco',
state: 'CA',
zip: '94103'
}).then(address => {
console.log(address);
});zipCodeLookup(object)
zipCodeLookup takes one parameter: object.
object: street1, street2, city, state
Example
const address = await usps.zipCodeLookup({
street1: '322 3rd st.',
street2: 'Apt 2',
city: 'San Francisco',
state: 'CA'
});
console.log(address);cityStateLookup(object)
cityStateLookup takes one parameter: zipcode.
zipcode: 5 digit zipcode as a string
Example
const result = await usps.cityStateLookup('94107');
console.log(result);