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");
|
return respostaComuns.erro("token_produto não informado");
|
||||||
const headers = {
|
const headers = {
|
||||||
token: token_produto,
|
token: token_produto,
|
||||||
|
"Content-Type": "application/json",
|
||||||
};
|
};
|
||||||
const parametros = {
|
const parametros = {
|
||||||
vinculos: { codigo_conta: conta, codigo_usuario, vinculo },
|
vinculos: { codigo_conta: conta, codigo_usuario, vinculo },
|
||||||
email: email,
|
email: email,
|
||||||
};
|
};
|
||||||
return node_fetch(url, {
|
return yield node_fetch(url, {
|
||||||
headers,
|
headers,
|
||||||
body: JSON.stringify(parametros),
|
body: JSON.stringify(parametros),
|
||||||
method: "POST",
|
method: "POST",
|
||||||
})
|
})
|
||||||
.then((r) => String(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}`))
|
.catch((e) => respostaComuns.erro(`Erro ao criar vinculo de usuario ${e.message}`));
|
||||||
.then((r) => r);
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -48,26 +48,35 @@ var usuarios_quipo_vincular = function (_a) {
|
||||||
return __awaiter(void 0, void 0, void 0, function () {
|
return __awaiter(void 0, void 0, void 0, function () {
|
||||||
var url, headers, parametros;
|
var url, headers, parametros;
|
||||||
return __generator(this, function (_b) {
|
return __generator(this, function (_b) {
|
||||||
url = "".concat((0, _urlAutenticacao_1.urlAutenticacao)(ambiente), "/api/vinculos__criar");
|
switch (_b.label) {
|
||||||
if (!token_produto)
|
case 0:
|
||||||
return [2 /*return*/, p_respostas_1.respostaComuns.erro("token_produto não informado")];
|
url = "".concat((0, _urlAutenticacao_1.urlAutenticacao)(ambiente), "/api/vinculos__criar");
|
||||||
headers = {
|
if (!token_produto)
|
||||||
token: token_produto,
|
return [2 /*return*/, p_respostas_1.respostaComuns.erro("token_produto não informado")];
|
||||||
};
|
headers = {
|
||||||
parametros = {
|
token: token_produto,
|
||||||
vinculos: { codigo_conta: conta, codigo_usuario: codigo_usuario, vinculo: vinculo },
|
"Content-Type": "application/json",
|
||||||
email: email,
|
};
|
||||||
};
|
parametros = {
|
||||||
return [2 /*return*/, (0, cross_fetch_1.default)(url, {
|
vinculos: { codigo_conta: conta, codigo_usuario: codigo_usuario, vinculo: vinculo },
|
||||||
headers: headers,
|
email: email,
|
||||||
body: JSON.stringify(parametros),
|
};
|
||||||
method: "POST",
|
return [4 /*yield*/, (0, cross_fetch_1.default)(url, {
|
||||||
})
|
headers: headers,
|
||||||
.then(function (r) { return String(r); })
|
body: JSON.stringify(parametros),
|
||||||
.catch(function (e) {
|
method: "POST",
|
||||||
return p_respostas_1.respostaComuns.erro("Erro ao criar vinculo de usuario ".concat(e.message));
|
})
|
||||||
})
|
.then(function (r) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
||||||
.then(function (r) { return r; })];
|
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",
|
"name": "p-drives",
|
||||||
"version": "0.93.0",
|
"version": "0.94.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|
|
||||||
|
|
@ -22,24 +22,22 @@ export const usuarios_quipo_vincular = async ({
|
||||||
const url = `${urlAutenticacao(ambiente)}/api/vinculos__criar`
|
const url = `${urlAutenticacao(ambiente)}/api/vinculos__criar`
|
||||||
|
|
||||||
if (!token_produto) return respostaComuns.erro("token_produto não informado")
|
if (!token_produto) return respostaComuns.erro("token_produto não informado")
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
token: token_produto,
|
token: token_produto,
|
||||||
|
"Content-Type": "application/json",
|
||||||
}
|
}
|
||||||
|
|
||||||
const parametros = {
|
const parametros = {
|
||||||
vinculos: { codigo_conta: conta, codigo_usuario, vinculo },
|
vinculos: { codigo_conta: conta, codigo_usuario, vinculo },
|
||||||
email: email,
|
email: email,
|
||||||
}
|
}
|
||||||
|
return await node_fetch(url, {
|
||||||
return node_fetch(url, {
|
|
||||||
headers,
|
headers,
|
||||||
body: JSON.stringify(parametros),
|
body: JSON.stringify(parametros),
|
||||||
method: "POST",
|
method: "POST",
|
||||||
})
|
})
|
||||||
.then((r) => String(r))
|
.then(async (r) => await r.json())
|
||||||
.catch((e) =>
|
.catch((e) =>
|
||||||
respostaComuns.erro(`Erro ao criar vinculo de usuario ${e.message}`),
|
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