Skip to content

jorgeitenjr/cep-finder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cep-finder

Easy CEP (brazilian postal code) finder.

Installation

npm install cep-finder

Usage

ES6 modules

import cepFinder from "cep-finder";

or CommonJS

const cepFinder = require("cep-finder");
cepFinder("01311300").then(result => console.log(result));

will produce the following object:

{
    logradouro: "Avenida Paulista",
    complemento: "de 1867 ao fim - lado ímpar",
    bairro: "Bela Vista",
    cidade: "São Paulo",
    estado: "SP",
    cep: "01311-300"
}

nodeJS:

When running in node by default the Correios page will be used. it is also possible use ViaCEP providing "webservice" as a second parameter:

cepFinder("01311300", "webservice").then(result => console.log(result));

browser:

To avoid CORS problems, ViaCEP is always used.

Tests

npm test

About

Easy CEP (brazilian postal code) finder.

Resources

License

Stars

Watchers

Forks

Packages

No packages published