update cep

This commit is contained in:
2026-01-06 09:47:37 -03:00
parent d7f66d929d
commit d222872000

View File

@@ -2,7 +2,8 @@ import { data } from 'react-router'
import type { Route } from './+types/route' import type { Route } from './+types/route'
export async function loader({ params }: Route.LoaderArgs) { 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' method: 'GET'
}) })
@@ -14,10 +15,10 @@ export async function loader({ params }: Route.LoaderArgs) {
return data({ return data({
postcode: json.cep.replace(/\D/g, ''), postcode: json.cep.replace(/\D/g, ''),
address1: json.logradouro, address1: json.street,
address2: json.complemento, address2: '',
neighborhood: json.bairro, neighborhood: json.neighborhood,
city: json.localidade, city: json.city,
state: json.uf state: json.state
}) })
} }