Skip to content

emensonlima01/viacep-integration-javascript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ViaCEP Integration JavaScript

Simple JavaScript examples using fetch to integrate with the ViaCEP webservice and map the response to a typed Address object.

Files

  • address.js: shared Address object used by both integrations.
  • via-cep-json.js: searches an address by ZIP code using JSON and maps the response to Address.
  • via-cep-xml.js: searches an address by ZIP code using XML and maps the response to Address.

Requirement

Use Node.js 18 or newer, because fetch is already available natively.

How to Run

Run the JSON example:

node via-cep-json.js

Run the XML example:

node via-cep-xml.js

API Used

Both examples use the official ViaCEP endpoint:

https://viacep.com.br/ws/01001000/json/
https://viacep.com.br/ws/01001000/xml/

References

About

Simple JavaScript examples using fetch to integrate with the ViaCEP webservice and map the response to a typed Address object.

Topics

Resources

Stars

Watchers

Forks

Contributors