update cep
This commit is contained in:
@@ -2,7 +2,8 @@ import { data } from 'react-router'
|
||||
import type { Route } from './+types/route'
|
||||
|
||||
export async function loader({ params }: Route.LoaderArgs) {
|
||||
const r = await fetch(`https://opencep.com/v1/${params.cep}`, {
|
||||
// const r = await fetch(`https://opencep.com/v1/${params.cep}`, {
|
||||
const r = await fetch(`https://brasilapi.com.br/api/cep/v1/${params.cep}`, {
|
||||
method: 'GET'
|
||||
})
|
||||
|
||||
@@ -14,10 +15,10 @@ export async function loader({ params }: Route.LoaderArgs) {
|
||||
|
||||
return data({
|
||||
postcode: json.cep.replace(/\D/g, ''),
|
||||
address1: json.logradouro,
|
||||
address2: json.complemento,
|
||||
neighborhood: json.bairro,
|
||||
city: json.localidade,
|
||||
state: json.uf
|
||||
address1: json.street,
|
||||
address2: '',
|
||||
neighborhood: json.neighborhood,
|
||||
city: json.city,
|
||||
state: json.state
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user