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

templates.get broken with v > 2.1.0 #220

Closed
joelabair opened this issue Sep 8, 2017 · 7 comments
Closed

templates.get broken with v > 2.1.0 #220

joelabair opened this issue Sep 8, 2017 · 7 comments
Assignees

Comments

@joelabair
Copy link

joelabair commented Sep 8, 2017

The error returned is 'SyntaxError: Unexpected token u'
When using the callback method.

"use strict";

var SparkPost = require('sparkpost');
var client = new SparkPost(); 
client.templates.get('my-id', function(err, res) {
	if (err) {
		console.error(err);
		return process.exit(1);
	} else {
		/* got it - continue */
	}
});
@aydrian aydrian self-assigned this Sep 8, 2017
@aydrian
Copy link
Contributor

aydrian commented Sep 8, 2017

Hi. I'm not getting the error. What version of node.js are you using?

@joelabair
Copy link
Author

v4.8.4

@aydrian
Copy link
Contributor

aydrian commented Sep 8, 2017

I first ran it with v6.11.2 and it worked. I also ran it with v4.8.4 and it also worked. I am using v2.1.2 of node-sparkpost.

@joelabair
Copy link
Author

Ok - I'll try to isolate the environment more.

@aydrian
Copy link
Contributor

aydrian commented Sep 8, 2017

Yeah. Maybe include a stack trace. Just let us know what you figure out.

@joelabair
Copy link
Author

My Bad. I was parsing res elsewhere in the code and the key 'body' is undefined. JSON.parse(res.body) Obviously a change in the 2.1.x series.

Sorry for the fire alarm. Thanks for your help.

@aydrian
Copy link
Contributor

aydrian commented Sep 8, 2017

Glad you were able to track it down. That was a change from 1.x to 2.x, the second argument is the data from the request. So it is res.body.

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