Comments (6)
as a side note, it would be GREAT if the data coming back (either from a promise or callback) could be JUST the response body and not the entire response object.
from intercom-node.
This issue is addressed in the beta version. Now, the SDK supports only a promise based approach. https://github.com/intercom/intercom-node/wiki/Migration-guide#no-more-callbacks
from intercom-node.
this is actually very dangerous behaviour. consider the case where a team has linting setup and marks that one of the arguments in the callback is not being utilized (for whatever reason). this will cause very unexpected behaviour if that team member removes the unused arg
from intercom-node.
Hi @mderazon
Just catching up with some older issues and wanted to follow up here.
Are you suggesting that it would be better to just have one version where accept two arguments and not allow the case for just the response?
I would be afraid now that people might be using this one argument method and would break if this was changed.
But I do see what you are saying. I am just not sure at present if it is something we would change. One option might be to remove one of the examples from the docs and leave the one with both arguments.
Will try and do some more digging here but let me know if you have any other thoughts in the mantime
Thanks
Cathal
from intercom-node.
@choran I really think the error handling should be fixed and released as a new major (breaking) version. This could also include the great suggestion by @stringbeans!
The current way the callback handler is called (counting the parameters provided to the callback) makes for easy errors to occur...
If you just want to send a request are not interested in the response body you'd have code such as this (pretty standard node code):
const event = {
event_name: 'some_event',
created_at: Math.round(Date.now() / 1000),
user_id: 'some user ID'
}
client.events.create(event, err => {
if (err) {
// Do something to handle the error
} else {
// Success - event created
}
})
Now with the current error handling this doesn't work:
- If the request errors the code actually crashes (I've created PR #191 to fix this).
- If the request succeeds the whole
response data
is returned to the callback which, with nodes error first callback style means the// Do something to handle the error
will be run - which is not what the consumer of your SDK wanted at all! - If the request fails (due to
error.list
in response) it works fine.
from intercom-node.
there is no standard error management ?
try {
await client....
} cath (err) {
}
from intercom-node.
Related Issues (20)
- Unable to pass customAttribute object to client.conversation.update() HOT 1
- Typo in type `RecepientType` (should be RecipientType) HOT 2
- I can not create a contact user. HOT 8
- Try to run boiler plate code in a node script either results in "SyntaxError: Cannot use import statement outside a module" or "Error [ERR_MODULE_NOT_FOUND]" HOT 1
- Unable to update by companyId with `client.companies.update`
- Type issue while using Intercom-Version headers HOT 1
- Small mistake in README - "import { Client } from './dist/index';" HOT 1
- Get Converting circular structure to JSON error when init Client
- How to import types ? HOT 1
- Unexpected behaviour using access token HOT 2
- Creating and Updating a Company - only companyId should be required
- Searching conversations with date fields always returns an empty result
- Do not throw undefined when the response body does not match the intercom API format
- Axios dependency version has critical vulnerability CVE-2023-45857 HOT 2
- createDataAttribute returns a 500
- ERROR | Unexpected error when using the `search` query on the `post` method HOT 1
- Intercom migration guide is missing HOT 1
- #2
- Unable to build 5.0.0 with TypeScript HOT 1
- `listAttachedTags` Method has wrong return type 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 intercom-node.