Skip to content

Commit 854946f

Browse files
committed
api post error handle
Signed-off-by: Samuel Hellawell <sshellawell@gmail.com>
1 parent 1c64b12 commit 854946f

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

api-example-send-credential/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ async function apiPost(url, body) {
1919
});
2020

2121
const data = await result.json();
22+
23+
if (result.status >= 400) {
24+
throw new Error(`API Error: ${data}`);
25+
}
26+
2227
return data;
2328
}
2429

0 commit comments

Comments
 (0)