31 lines
858 B
JavaScript
31 lines
858 B
JavaScript
import cFetch from "cross-fetch";
|
|
import { respostaComuns } from "p-respostas";
|
|
const tx_usuarios__listar = "usuarios__listar";
|
|
const listarUsuarios = async ({
|
|
token,
|
|
url_api_autenticacao
|
|
}, parametros) => {
|
|
const url = `${url_api_autenticacao}/api/${tx_usuarios__listar}`;
|
|
return cFetch(url, {
|
|
headers: { token, "Content-Type": "application/json" },
|
|
body: JSON.stringify(parametros),
|
|
method: "post"
|
|
}).then(async (a) => {
|
|
const texto = await a.text();
|
|
try {
|
|
const res = JSON.parse(texto);
|
|
return res;
|
|
} catch (error) {
|
|
return respostaComuns.erro(
|
|
`Erro ao listar usu\xE1rios: ${error.message}`,
|
|
[texto, error]
|
|
);
|
|
}
|
|
}).catch(
|
|
(error) => respostaComuns.erro(`Erro ao listar usu\xE1rios: ${error.message}`, [error])
|
|
);
|
|
};
|
|
export {
|
|
listarUsuarios,
|
|
tx_usuarios__listar
|
|
};
|