Skip to content

Commit

Permalink
add statusCode to request Promise fulfilment
Browse files Browse the repository at this point in the history
  • Loading branch information
idokleinman committed Nov 17, 2015
1 parent bfe7f2d commit d95fb57
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@particle/api",
"version": "3.0.3",
"version": "3.0.4",
"description": "Particle API Client",
"main": "lib/Particle.js",
"scripts": {
Expand Down
7 changes: 5 additions & 2 deletions src/Particle.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,18 @@ class Particle {
req.send(form);
}
req.end((error, res) => {
const body = res && res.body;
let body = res && res.body;
if (error) {
const code = error.status;
let errorDescription = `${ code ? 'HTTP error' : 'Network error' } ${ code } from ${ uri }`;
if (body && body.error_description) { errorDescription += ' - ' + body.error_description; }
reject({ code, errorDescription, error });
}
else {
fulfill(body);
fulfill({
body: body,
statusCode: res.statusCode,
});
}
});
});
Expand Down

0 comments on commit d95fb57

Please sign in to comment.