2.0.2 • Published 3 years ago

@postalcode/service-viacep v2.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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

contributors

@weltongbi

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.1.1

3 years ago

1.0.1

3 years ago

0.1.5

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago