@lokalise/node-api
Advanced tools
Comparing version 1.5.0-rc1 to 2.0.0
# Lokalise API Node Client Changelog | ||
## 1.5.0 | ||
## 2.0.0 (05-Dec-19) | ||
* Added [error handling mechanism](https://github.com/lokalise/node-lokalise-api#error-handling) | ||
* Updated dependencies | ||
## 1.5.0-rc.1 (04-Dec-19) | ||
* Set `noImplicitAny` and `strictNullChecks` to `true` in `tsconfig.json` | ||
@@ -6,0 +11,0 @@ * Fixed errors related to the options above |
@@ -43,2 +43,5 @@ "use strict"; | ||
} | ||
populateApiErrorFromJson(json) { | ||
return json; | ||
} | ||
returnBareJSON(json) { | ||
@@ -48,4 +51,3 @@ return json; | ||
handleReject(data) { | ||
console.log(data); | ||
return; | ||
return this.populateApiErrorFromJson(data); | ||
} | ||
@@ -52,0 +54,0 @@ createPromise(method, params, resolveFn, rejectFn = this.handleReject, body = null, uri = null) { |
{ | ||
"name": "@lokalise/node-api", | ||
"version": "1.5.0-rc1", | ||
"version": "2.0.0", | ||
"description": "Official Lokalise API 2.0 Node.js client", | ||
@@ -40,3 +40,3 @@ "license": "MIT", | ||
"request": "^2.88.0", | ||
"typescript": "^3.7.2" | ||
"typescript": "^3.7.3" | ||
}, | ||
@@ -43,0 +43,0 @@ "bugs": { |
@@ -884,2 +884,12 @@ # Lokalise API v2 official Node.js client | ||
To handle request errors, you may use the following approach: | ||
```js | ||
lokaliseApi.projects.list().catch( | ||
(e) => { | ||
console.log(e); | ||
} | ||
); | ||
``` | ||
[Error codes](https://lokalise.com/api2docs/curl/#resource-errors) are listed in the API docs. | ||
@@ -886,0 +896,0 @@ |
import { ApiRequest } from '../http_client/base'; | ||
import { StandartParams } from '../interfaces/standart_params'; | ||
import { ApiError } from '../models/api_error'; | ||
@@ -57,9 +58,12 @@ export class BaseCollection { | ||
protected returnBareJSON(json: any) : any { | ||
protected populateApiErrorFromJson(json: Object): ApiError { | ||
return <ApiError>json; | ||
} | ||
protected returnBareJSON(json: any): any { | ||
return json; | ||
} | ||
protected handleReject(data: any) { | ||
console.log(data); | ||
return; | ||
protected handleReject(data: any): ApiError { | ||
return this.populateApiErrorFromJson(data); | ||
} | ||
@@ -66,0 +70,0 @@ |
@@ -0,1 +1,3 @@ | ||
import {ApiError} from "../../src/interfaces/api_error"; | ||
require('../setup'); | ||
@@ -12,2 +14,10 @@ import { expect } from 'chai'; | ||
deck.createTest('error', async () => { | ||
const error = await lokaliseApi.branches.create({ | ||
"name": "hotfix/really-important" | ||
}, { project_id: "803" }).catch((e: ApiError) => { | ||
expect(e.code).to.equal(401); | ||
}); | ||
}).register(this); | ||
deck.createTest('list', async () => { | ||
@@ -14,0 +24,0 @@ const branches = await lokaliseApi.branches.list({project_id: project_id}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
773453
355
3663
0
917
Updatedtypescript@^3.7.3