build
This commit is contained in:
parent
a6205f1ab6
commit
e580643abc
40 changed files with 329 additions and 507 deletions
|
|
@ -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[]>)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue