I'm trying to get Oboe to send some data with the request, but it doesn't seem to work. This is my simple test script, I have also included a request.js example which works fine:
// Doesn't work
var oboe = require('oboe');
oboe({
method: 'POST',
url: 'http://localhost:8440/oboe.php',
body: JSON.stringify({
foo: 'bar',
}),
}).done(function(data) {
console.log('oboe', data);
});
// Works
var request = require('request');
request({
json: true,
method: 'POST',
url: 'http://localhost:8440/oboe.php',
body: JSON.stringify({
foo: 'bar',
}),
}, function(error, response, body) {
console.log('request', body);
});
This outputs:
$ node test.js
oboe { get: [], post: [], body: '' }
request { get: [], post: [], body: '"{\\"foo\\":\\"bar\\"}"' }
And my simple PHP file for testing:
<?php
die(json_encode([
'get' => $_GET,
'post' => $_POST,
'body' => file_get_contents('php://input'),
]));
I'm sure I'm doing something simple wrong, but can't figure out what.
via Petah
No comments:
Post a Comment