Comments (6)
Sure. I'll check that
from node-module-glpi.
This issue is already resolved, it includes handling errors when returning a failed response that should be able to prevent this from happening again.
I already changed the way I handle the errors, I no longer make them an object and I split the error message in the semicolon as I was asked. Thus we see a message of a failed request in the library:
{
status: 401,
data: [
'ERROR_GLPI_LOGIN',
'Incorrect username or password'
]
}
I have not withdrawn the status of the object returned since although it is true that users could know if they are in the presence of an error without the presence of these, it is also true that there is always the possibility that to someone this fact is a useful one.
from node-module-glpi.
When the API does not return a JSON code I got a SyntaxError about the Unexpected token.
Instead print a proper error message in JSON file format.
node example-initSessionByCredentials.js
undefined:1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
^
SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse (<anonymous>)
at _prepareRequest (/Users/<user>/GitHub/glpi/node-module-glpi/lib/restclient.js:78:31)
at IncomingMessage.resp.on (/Users/<user>/GitHub/glpi/node-module-glpi/lib/restclient.js:59:5)
at emitNone (events.js:110:20)
at IncomingMessage.emit (events.js:207:7)
at endReadableNT (_stream_readable.js:1059:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
<user>:example <user>$
from node-module-glpi.
In the method killSession, when no session token the promise is rejected with a text message: "Uninitialized session" (https://git.io/vFv2D) but for resolve you use the format in JSON.
An example for a message in the reject:
{
status: 400,
data: [
'ERROR_SESSION_TOKEN_MISSING',
'....'
]
}
Reference: https://git.io/vFv2o
from node-module-glpi.
Hi, @Gianfranco97
Could you split the error message in the semicolon to clean the error message?
Example:
missing parameter app_token; view documentation in your browser at https://dev.flyve.org/glpi/apirest.php/#ERROR_APP_TOKEN_PARAMETERS_MISSING
Output
missing parameter app_token
from node-module-glpi.
I think, is better to print only "data"
For "success" and "fails".
from node-module-glpi.
Related Issues (20)
- Code documentation
- Wiki article per API method HOT 1
- Problems with status 300
- Compile and minify library
- Change circleci to travis
- Wrong way to use promises HOT 1
- Update code samples
- 504 Gateway Time-out
- An in-range update of webpack is breaking the build 🚨 HOT 20
- Migrate project site information to glpi-project.org
- An in-range update of webpack is breaking the build 🚨 HOT 37
- An in-range update of uglifyjs-webpack-plugin is breaking the build 🚨 HOT 5
- An in-range update of webpack-cli is breaking the build 🚨 HOT 13
- An in-range update of babel-loader is breaking the build 🚨 HOT 3
- Tests fail on Circle CI
- An in-range update of eslint is breaking the build 🚨 HOT 6
- An in-range update of eslint-plugin-promise is breaking the build 🚨 HOT 3
- An in-range update of eslint-plugin-import is breaking the build 🚨 HOT 10
- An in-range update of eslint-plugin-node is breaking the build 🚨 HOT 1
- An in-range update of eslint-plugin-standard is breaking the build 🚨 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-module-glpi.