1 Commits

Author SHA1 Message Date
43b7800ed6 fix: phin handle 400 empty body
phin doesn't throw on 400 and instead passes empty body to tg
2022-01-18 19:39:15 +03:00
2 changed files with 5 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "ussd-tg-proxy",
"version": "0.3.0",
"version": "0.3.1",
"description": "ussd-tg-proxy",
"main": "src/index.js",
"repository": "https://git.grassecon.net/grassrootseconomics/ussd-tg-proxy.git",

View File

@@ -21,7 +21,10 @@ async function proxy(sessionId, phone, input = "") {
try {
const { body } = await phin(requestOptions);
log.debug({ body: body }, "response body");
return body;
if (body.length > 1) {
return body;
}
throw new Error("empty body");
} catch (error) {
log.error(error);
return "ERR Something went wrong, try again later.";