我对Node.js很新 我尝试使用Node js将Twitter推文呈现给ejs文件,但收到以下错误:
SyntaxError: Unexpected token ) in C:\achu\samples\nodejs\oneNode\oneNode\views\tweets.ejs while compiling ejs
at Function (native)
at Object.Template.compile (C:\achu\samples\nodejs\oneNode\oneNode\node_modules\ejs\lib\ejs.js:485:12)
at Object.compile (C:\achu\samples\nodejs\oneNode\oneNode\node_modules\ejs\lib\ejs.js:289:16)
at handleCache (C:\achu\samples\nodejs\oneNode\oneNode\node_modules\ejs\lib\ejs.js:148:16)
at View.exports.renderFile [as engine] (C:\achu\samples\nodejs\oneNode\oneNode\node_modules\ejs\lib\ejs.js:358:14)
at View.render (C:\achu\samples\nodejs\oneNode\oneNode\node_modules\express\lib\view.js:126:8)
at tryRender (C:\achu\samples\nodejs\oneNode\oneNode\node_modules\express\lib\application.js:639:10)
at EventEmitter.render (C:\achu\samples\nodejs\oneNode\oneNode\node_modules\express\lib\application.js:591:3)
at ServerResponse.render (C:\achu\samples\nodejs\oneNode\oneNode\node_modules\express\lib\response.js:961:7)
at C:\achu\samples\nodejs\oneNode\oneNode\expressDemo.js:17:18
代码如下:
var express = require("express");
var app = express();
var twitter = require("twitter");
var client = new twitter({
consumer_key: "##################",
consumer_secret: "##################",
access_token_key: "##################-##################",
access_token_secret: "##################"
});
//app.set('view engine', 'ejs');
app.get("/:username", function (request, response) {
var username = request.params.username;
client.get("search/tweets", { q: username }, function (error, tweets, res) {
response.locals = { tweets: tweets, name: 'someusername' };
response.render("tweets.ejs");
});
}).listen(8080);
有人可以帮我解决这个问题吗?