This commit is contained in:
Luiz H. R. Silva 2024-06-19 17:47:48 -03:00
parent a6205f1ab6
commit e580643abc
40 changed files with 329 additions and 507 deletions

View file

@ -1,3 +1,4 @@
import node_fetch from "cross-fetch"
import { respostaComuns, type tipoResposta } from "p-respostas"
import type { z } from "zod"
import type { zAmbiente } from "../ts/ambiente"
@ -15,14 +16,9 @@ export type tipoUsuarioExterno = {
export const usuarios_quipo_governo = async ({
token_produto,
ambiente,
buscar,
}: {
ambiente: z.infer<typeof zAmbiente>
token_produto: string
buscar: (
url: string,
headers: { [k: string]: string },
) => Promise<tipoResposta<tipoUsuarioExterno[]>>
}): Promise<tipoResposta<tipoUsuarioExterno[]>> => {
const url = `${urlAutenticacao(ambiente)}/api/usuarios_quipo_governo`
@ -32,7 +28,12 @@ export const usuarios_quipo_governo = async ({
token: token_produto,
}
return buscar(url, headers).catch((e) =>
respostaComuns.erro(`erro ao buscar usuários quipo governo: ${e}`),
)
return node_fetch(url, {
headers,
})
.then((r) => r.json())
.catch((e) =>
respostaComuns.erro("Erro ao buscar usuários quipo governo", [e.message]),
)
.then((r) => r as tipoResposta<tipoUsuarioExterno[]>)
}