Skip to content

Commit 266e7bf

Browse files
committed
Ensure body is an object before checking for an error
1 parent 1556092 commit 266e7bf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/requestwrapper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function formatErrorIfExists(cb) {
6868
}
6969

7070
// If we have a response and it contains an error
71-
if (body && (body.error || body.error_code)) {
71+
if (typeof body === 'object' && (body.error || body.error_code)) {
7272
// visual recognition sets body.error to a json object with code/description/error_id instead of putting them top-left
7373
if (typeof body.error === 'object' && body.error.description) {
7474
const errObj = body.error; // just in case there's a body.error.error...

0 commit comments

Comments
 (0)