Reputation: 11064
I am trying to use the .post() convenience method of the Javascript/Node module request. Does it accept a callback? I don't understand why it would be complaining about this:
var request = require('request');
request.post({url: 'https://identity.api.foo/v2.0', body: JSON.stringify({
'auth': {
"KSKEY:apiKeyCredentials": {
"username": "joe",
"apiKey": "10677bad"
}
}
}), function (e, r, body) {
console.log(e);
console.log(r);
console.log(body);
});
one@node ~ $ node try.js
/home/one/try.js:9
}), function (e, r, body) {
^
SyntaxError: Unexpected token (
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
one@node ~ $
EDIT: Just a follow up...I am using restler instead and I find it to be way better. - for anyone that is in the same need of a tool like this.
Upvotes: 0
Views: 73
Reputation: 1235
You need to close the object you're passing in before the second argument (the callback);
var request = require('request');
request.post({url: 'https://identity.api.foo/v2.0', body: JSON.stringify({
'auth': {
"KSKEY:apiKeyCredentials": {
"username": "joe",
"apiKey": "10677bad"
}
}
})
}, function...
Upvotes: 1