我正在研究简单的 Node js 模块...... 一个模块,当我给出一个 ID 和一个请求率时,返回一个可读流,该流为相应的卫星发出位置数据...... 我正在尝试通过使用子类 ReadableStream 来实现
http://nodejs.org/api/stream.html#stream_class_stream_readable
我正在使用这个接口(interface)
https://api.wheretheiss.at/v1/satellites/25544
在下面提供我的代码..
http://jsfiddle.net/omb3rwqn/1/
var request = require('request');
var url = 'https://api.wheretheiss.at/v1/satellites/25544'
var reader = request(url);
readable.on('readable', function() {
console.log('got %d characters of string data');
})
最佳答案
你有没有在你的 app.js 端点发生意外
app.post('/api/v1/something',function(req,res)
{
var ip = req.headers['x-forwarded-for'];
**var a = request.connection.remoteAddress**
在这种情况下,您代码中的“请求”是一个转移注意力的问题。您真正要寻找的是您的端点定义了“请求”(或请求以外的任何内容)这一事实
关于javascript - Uncaught ReferenceError : request is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26077052/