Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send not handling error callback #6

Open
summanerd opened this issue May 29, 2017 · 3 comments
Open

send not handling error callback #6

summanerd opened this issue May 29, 2017 · 3 comments

Comments

@summanerd
Copy link

I'm getting the following error

TypeError: Cannot read property 'ok' of null
               at .../node_modules/apostle.io/lib/index.js:37:10

the function at this location

(request || superagent)
		.post(apostle.deliveryEndpoint)
		.type('json')
		.send(payload)
		.set('Authorization', 'Bearer ' + apostle.domainKey)
		.set('Apostle-Client', 'JavaScript/v0.1.1')
		.end(function(res){
			if(res.ok){
				promise.fulfill()
			}else{
				promise.reject('error', res)
			}
		})

when I add a param to handle the possible error all is well. When I look at superagent package, I confirmed they use the error first callback pattern common in node.

I will create a pull request as this is breaking my current project. if this is in fact an error please. Otherwise please assist.

@snikch
Copy link
Member

snikch commented May 29, 2017

Hey there, a PR would be great. We recently upgraded the superagent package due to security concerns, so it's likely this broke it. Thanks!

@summanerd
Copy link
Author

done. I could also add some unit tests that could catch this type of thing. It would require some updates to sinon package and maybe the test process. Let me know if you would like me to do another PR.

@snikch
Copy link
Member

snikch commented Jun 5, 2017

If you're happy to add these tests, they would be much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants