fix: phin handle 400 empty body
phin doesn't throw on 400 and instead passes empty body to tg
This commit is contained in:
parent
30b60899d5
commit
43b7800ed6
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ussd-tg-proxy",
|
"name": "ussd-tg-proxy",
|
||||||
"version": "0.3.0",
|
"version": "0.3.1",
|
||||||
"description": "ussd-tg-proxy",
|
"description": "ussd-tg-proxy",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"repository": "https://git.grassecon.net/grassrootseconomics/ussd-tg-proxy.git",
|
"repository": "https://git.grassecon.net/grassrootseconomics/ussd-tg-proxy.git",
|
||||||
|
@ -21,7 +21,10 @@ async function proxy(sessionId, phone, input = "") {
|
|||||||
try {
|
try {
|
||||||
const { body } = await phin(requestOptions);
|
const { body } = await phin(requestOptions);
|
||||||
log.debug({ body: body }, "response body");
|
log.debug({ body: body }, "response body");
|
||||||
return body;
|
if (body.length > 1) {
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
throw new Error("empty body");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(error);
|
log.error(error);
|
||||||
return "ERR Something went wrong, try again later.";
|
return "ERR Something went wrong, try again later.";
|
||||||
|
Loading…
Reference in New Issue
Block a user