drivers/dist-import/autenticacao/_validarToken.js
2024-07-01 12:55:34 -03:00

21 lines
697 B
JavaScript

import { urlAutenticacao } from "./_urlAutenticacao";
import node_fetch from "cross-fetch";
/** faz a validação do token */
export const validarToken = async ({ ambiente, post, }) => {
const url = `${urlAutenticacao(ambiente)}/api/validar_token`;
try {
const resposta = await node_fetch(url, {
method: "POST",
body: JSON.stringify(post),
headers: { "Content-Type": "application/json" },
})
.then((r) => r.json())
.then((r) => r)
.then((resposta) => resposta.eCerto ? "valido" : "erro")
.catch(() => "erro");
return resposta;
}
catch (e) {
return "erro";
}
};