Проблема с модулем Async на удаленном сервере
Я получаю проблему на моем удаленном сервере с модулем Async, используемым с ExpressJS, он работает локально, но не на моем удаленном сервере...
SyntaxError: Unexpected token <
at Object.parse (native)
at /home/anthoc/apps/instaprint.fr/routes/index.js:62:20
at fn (/home/anthoc/apps/instaprint.fr/node_modules/async/lib/async.js:582:34)
at Object._onImmediate (/home/anthoc/apps/instaprint.fr/node_modules/async/lib/async.js:498:34)
at processImmediate [as _immediateCallback] (timers.js:330:15)
Мой код:
async.waterfall([
function (callback) {
var postData = {
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET,
grant_type: 'authorization_code',
redirect_uri: REDIRECT_URI,
code: CODE
}
var url = 'https://api.instagram.com/oauth/access_token';
request.post({
uri: url,
form: postData
}, function (err, res, body) {
callback(null,body);
});
}, function (body, callback) {
var data = JSON.parse(body);
TOKEN = data.access_token;
USER_ID = data.user.id;
callback(null);
}], function (err, result) {
res.redirect('/photos');
}
);
РЕДАКТИРОВАНИЕ № 1:
Результат "console.log(body)":
<html><body><h1>500 Server Error</h1>
An internal server error occured.
</body></html>
РЕДАКТИРОВАТЬ № 2:
SyntaxError: Unexpected token <
at Object.parse (native)
at /home/anthoc/apps/instaprint.fr/routes/index.js:63:20
at fn (/home/anthoc/apps/instaprint.fr/node_modules/async/lib/async.js:582:34)
at Object._onImmediate (/home/anthoc/apps/instaprint.fr/node_modules/async/lib/async.js:498:34)
at processImmediate [as _immediateCallback] (timers.js:330:15)
Код:
async.waterfall([
function (callback) {
var postData = {
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET,
grant_type: 'authorization_code',
redirect_uri: REDIRECT_URI,
code: CODE
}
var url = 'https://api.instagram.com/oauth/access_token';
request.post({
uri: url,
form: postData
}, function (err, res, body) {
callback(null,body);
});
}, function (body, callback) {
res.setHeader('content-type', 'application/json');
req.accepts('application/json');
var data = JSON.parse(body);
TOKEN = data.access_token;
USER_ID = data.user.id;
callback(null);
}], function (err, result) {
res.redirect('/photos');
}
);