@postalcode/service-viacep
v2.0.2
Published
Plugin for postalcode
Downloads
25
Maintainers
Readme
service-viacep
Plugin service for postalcode
Plugin for PostalCode
import PostalCode from "@postalcode/postalcode";
import serviceViacep, { ServiceOptions } from "@postalcode/service-viacep";
const postalCode = new PostalCode({
/* All Postal Code Options*/
});
postCode.use<ServiceOptions>(serviceViacep, {
/* All Service Options*/
});
viaCep.get("05010000").then(console.log);
// {
// "postalcode": "05010000",
// "state": "SP",
// "city": "São Paulo",
// "street": "Rua Caiubí",
// "neighborhood": "Perdizes",
// }
Use direct Service.
import ViaCepService from "@postalcode/service-viacep";
const viaCep = new ViaCepService();
viaCep.get("05010000").then(console.log);
// {
// "postalcode": "05010000",
// "state": "SP",
// "city": "São Paulo",
// "street": "Rua Caiubí",
// "neighborhood": "Perdizes",
// }
Installation
Browser using CDN
<script src="https://unpkg.com/@postalcode/service-viacep@latest/dist/index.min.js"></script>
<script>
const viaCep = new serviceViacep({
/* Service configs*/
});
viaCep.get("05010000").then(console.log);
// {
// "postalcode": "05010000",
// "state": "SP",
// "city": "São Paulo",
// "street": "Rua Caiubí",
// "neighborhood": "Perdizes",
// }
</script>
npm
$ npm install --save @postalcode/service-viacep
yarn
$ yarn add @postalcode/service-viacep
Typescript
import serviceViacep from "@postalcode/service-viacep";
const viaCep = new serviceViacep();
viaCep.name;
viaCep.type;
viaCep.country;
viaCep.codeLength;
viaCep.get("05010000").then(console.log);
// {
// "postalcode": "05010000",
// "state": "SP",
// "city": "São Paulo",
// "street": "Rua Caiubí",
// "neighborhood": "Perdizes",
// }
how to contribute
Read our contribution guide here