ajuste na funcao de node_fetch
This commit is contained in:
parent
059780f4c4
commit
84e3b9d377
4 changed files with 37 additions and 30 deletions
|
|
@ -16,17 +16,17 @@ export const usuarios_quipo_vincular = ({ token_produto, ambiente, conta, vincul
|
|||
return respostaComuns.erro("token_produto não informado");
|
||||
const headers = {
|
||||
token: token_produto,
|
||||
"Content-Type": "application/json",
|
||||
};
|
||||
const parametros = {
|
||||
vinculos: { codigo_conta: conta, codigo_usuario, vinculo },
|
||||
email: email,
|
||||
};
|
||||
return node_fetch(url, {
|
||||
return yield node_fetch(url, {
|
||||
headers,
|
||||
body: JSON.stringify(parametros),
|
||||
method: "POST",
|
||||
})
|
||||
.then((r) => String(r))
|
||||
.catch((e) => respostaComuns.erro(`Erro ao criar vinculo de usuario ${e.message}`))
|
||||
.then((r) => r);
|
||||
.then((r) => __awaiter(void 0, void 0, void 0, function* () { return yield r.json(); }))
|
||||
.catch((e) => respostaComuns.erro(`Erro ao criar vinculo de usuario ${e.message}`));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -48,26 +48,35 @@ var usuarios_quipo_vincular = function (_a) {
|
|||
return __awaiter(void 0, void 0, void 0, function () {
|
||||
var url, headers, parametros;
|
||||
return __generator(this, function (_b) {
|
||||
url = "".concat((0, _urlAutenticacao_1.urlAutenticacao)(ambiente), "/api/vinculos__criar");
|
||||
if (!token_produto)
|
||||
return [2 /*return*/, p_respostas_1.respostaComuns.erro("token_produto não informado")];
|
||||
headers = {
|
||||
token: token_produto,
|
||||
};
|
||||
parametros = {
|
||||
vinculos: { codigo_conta: conta, codigo_usuario: codigo_usuario, vinculo: vinculo },
|
||||
email: email,
|
||||
};
|
||||
return [2 /*return*/, (0, cross_fetch_1.default)(url, {
|
||||
headers: headers,
|
||||
body: JSON.stringify(parametros),
|
||||
method: "POST",
|
||||
})
|
||||
.then(function (r) { return String(r); })
|
||||
.catch(function (e) {
|
||||
return p_respostas_1.respostaComuns.erro("Erro ao criar vinculo de usuario ".concat(e.message));
|
||||
})
|
||||
.then(function (r) { return r; })];
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
url = "".concat((0, _urlAutenticacao_1.urlAutenticacao)(ambiente), "/api/vinculos__criar");
|
||||
if (!token_produto)
|
||||
return [2 /*return*/, p_respostas_1.respostaComuns.erro("token_produto não informado")];
|
||||
headers = {
|
||||
token: token_produto,
|
||||
"Content-Type": "application/json",
|
||||
};
|
||||
parametros = {
|
||||
vinculos: { codigo_conta: conta, codigo_usuario: codigo_usuario, vinculo: vinculo },
|
||||
email: email,
|
||||
};
|
||||
return [4 /*yield*/, (0, cross_fetch_1.default)(url, {
|
||||
headers: headers,
|
||||
body: JSON.stringify(parametros),
|
||||
method: "POST",
|
||||
})
|
||||
.then(function (r) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, r.json()];
|
||||
case 1: return [2 /*return*/, _a.sent()];
|
||||
}
|
||||
}); }); })
|
||||
.catch(function (e) {
|
||||
return p_respostas_1.respostaComuns.erro("Erro ao criar vinculo de usuario ".concat(e.message));
|
||||
})];
|
||||
case 1: return [2 /*return*/, _b.sent()];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "p-drives",
|
||||
"version": "0.93.0",
|
||||
"version": "0.94.0",
|
||||
"description": "",
|
||||
"main": "src/index.ts",
|
||||
"exports": {
|
||||
|
|
|
|||
|
|
@ -22,24 +22,22 @@ export const usuarios_quipo_vincular = async ({
|
|||
const url = `${urlAutenticacao(ambiente)}/api/vinculos__criar`
|
||||
|
||||
if (!token_produto) return respostaComuns.erro("token_produto não informado")
|
||||
|
||||
const headers = {
|
||||
token: token_produto,
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
const parametros = {
|
||||
vinculos: { codigo_conta: conta, codigo_usuario, vinculo },
|
||||
email: email,
|
||||
}
|
||||
|
||||
return node_fetch(url, {
|
||||
return await node_fetch(url, {
|
||||
headers,
|
||||
body: JSON.stringify(parametros),
|
||||
method: "POST",
|
||||
})
|
||||
.then((r) => String(r))
|
||||
.then(async (r) => await r.json())
|
||||
.catch((e) =>
|
||||
respostaComuns.erro(`Erro ao criar vinculo de usuario ${e.message}`),
|
||||
)
|
||||
.then((r) => r as tipoResposta<string>)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue