Compare commits

...

2 Commits

Author SHA1 Message Date
dependabot[bot]
36efc8767d Bump path-parse from 1.0.6 to 1.0.7
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-11 04:20:41 +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 14 deletions

14
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": {
@@ -6023,9 +6023,9 @@
}
},
"os": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/os/-/os-0.1.1.tgz",
"integrity": "sha1-IIhF6J4ZOtTZcUdLk5R3NqVtE/M="
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/os/-/os-0.1.2.tgz",
"integrity": "sha512-ZoXJkvAnljwvc56MbvhtKVWmSkzV712k42Is2mA0+0KTSRakq5XXuXpjZjgAt9ctzl51ojhQWakQQpmOvXWfjQ=="
},
"ow": {
"version": "0.4.0",
@@ -6122,9 +6122,9 @@
"dev": true
},
"path-parse": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
"integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==",
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
"dev": true
},
"path-type": {

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
},
};