远程服务器上的Async模块问题

时间:2014-03-19 21:06:29

标签: node.js node-modules

我的远程服务器上出现了与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:

&#34; console.log(body)&#34;的结果:

 <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');
    }
);

0 个答案:

没有答案