Node.js NodeJS推特API没有';不要发送推特
我在GitHub twit NPM中找到并使用以下代码创建应用程序:Node.js NodeJS推特API没有';不要发送推特,node.js,Node.js,我在GitHub twit NPM中找到并使用以下代码创建应用程序: -> express twitter -> in the app.js: var T = new Twit({ consumer_key: 'AAA', consumer_secret: 'BBB', access_token: 'CCC', access_token_secret: 'DDD' }) T.post('/update', { status: 'hel
-> express twitter
-> in the app.js:
var T = new Twit({
consumer_key: 'AAA',
consumer_secret: 'BBB',
access_token: 'CCC',
access_token_secret: 'DDD'
})
T.post('/update', { status: 'hello world!' }, function(err, data, response) {
console.log(data)
})
// I write it in the end of whole code that generated by express. But when I start
it with the comand node app.js it prints "undefined" and 404 Not Found when
I run it from browser.
谁知道,我怎样才能解决这个问题?我也有路由文件夹。但是除了express生成的代码之外,我没有其他任何东西
屏幕截图:好的,有两个问题
没有理由使用浏览器查看结果。您需要设置一个路由来完成此操作。app.js的第30行是什么?
app.use(function(req,res,next){var err=new Error('Not Found');err.status=404;next(err);})
当我转到localhost:3000/update
@ryan删除或注释该行并重试时,会出现此错误。app.use()将在我认为您不需要的每个请求上运行该函数。除非您知道有问题,否则您不想调用next(err)。如果没有问题,您的中间件应该只调用next()@Ryan现在打印无法获取/更新