Compare commits

...

2 Commits

Author SHA1 Message Date
dependabot[bot]
9f59bf79b2 Bump node-notifier from 8.0.0 to 8.0.1
Bumps [node-notifier](https://github.com/mikaelbr/node-notifier) from 8.0.0 to 8.0.1.
- [Release notes](https://github.com/mikaelbr/node-notifier/releases)
- [Changelog](https://github.com/mikaelbr/node-notifier/blob/v8.0.1/CHANGELOG.md)
- [Commits](https://github.com/mikaelbr/node-notifier/compare/v8.0.0...v8.0.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-22 04:20:05 +00:00
Martin M
5a07f6b615 Release v3.1.1 (#112)
* fix JSON parse error when device is offline (#111)

* add 503 error and fix makeRequest mixin when device is Offline or Service is unavailable

* add 503 error and fix makeRequest mixin when device is Offline or Service is unavailable

* version bump

Co-authored-by: Luigui Delyer <git@s1x.com.br>
2020-10-18 19:17:16 -03:00
4 changed files with 14 additions and 19 deletions

19
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "ewelink-api",
"version": "3.1.0",
"version": "3.1.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -3480,8 +3480,7 @@
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=",
"dev": true,
"optional": true
"dev": true
},
"har-schema": {
"version": "2.0.0",
@@ -3965,7 +3964,6 @@
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
"dev": true,
"optional": true,
"requires": {
"is-docker": "^2.0.0"
}
@@ -5810,11 +5808,10 @@
"dev": true
},
"node-notifier": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.0.tgz",
"integrity": "sha512-46z7DUmcjoYdaWyXouuFNNfUo6eFa94t23c53c+lG/9Cvauk4a98rAUp9672X5dxGdQmLpPzTxzu8f/OeEPaFA==",
"version": "8.0.1",
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.1.tgz",
"integrity": "sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==",
"dev": true,
"optional": true,
"requires": {
"growly": "^1.3.0",
"is-wsl": "^2.2.0",
@@ -6836,8 +6833,7 @@
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
"integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==",
"dev": true,
"optional": true
"dev": true
},
"side-channel": {
"version": "1.0.3",
@@ -7841,8 +7837,7 @@
"version": "8.3.1",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz",
"integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==",
"dev": true,
"optional": true
"dev": true
},
"v8-compile-cache": {
"version": "2.1.1",

View File

@@ -1,6 +1,6 @@
{
"name": "ewelink-api",
"version": "3.1.0",
"version": "3.1.1",
"description": "eWeLink API for Node.js",
"author": "Martín M.",
"license": "MIT",

View File

@@ -5,6 +5,7 @@ const errors = {
403: 'Forbidden',
404: 'Device does not exist',
406: 'Authentication failed',
503: 'Service Temporarily Unavailable or Device is offline'
};
const customErrors = {

View File

@@ -42,14 +42,13 @@ module.exports = {
const requestUrl = `${apiUrl}${uri}${queryString}`;
const request = await fetch(requestUrl, payload);
const response = await request.json();
const error = _get(response, 'error', false);
if (error) {
return { error, msg: errors[error] };
if (!request.ok) {
return { error: request.status, msg: errors[request.status] };
}
return response;
const response = await request.json();
return response
},
};