Now let's create an express server which queries out for this search term and just returns the json. You'll need to do a few things:

  • Require the express module
  • Create the express server 'app'
  • On a get request to '/', pipe the request(searchURL) to the response.
  • Tell the app to listen on port 8080
var url = require('url');
var request = require('request');
var express = require('express');

options = {
  protocol: "http:",
  host: "search.twitter.com",
  pathname: '/search.json',
  query: { q: "codeschool"}
};

var searchURL = url.format(options);

var app = express.createServer();
app.get('/', function(req, response){
    request(searchURL).pipe(response);
});  
app.listen(8080);

 

相关文章:

  • 2022-12-23
  • 2021-07-19
  • 2021-06-14
  • 2021-12-26
  • 2021-06-12
  • 2022-12-23
  • 2022-02-11
  • 2021-09-07
猜你喜欢
  • 2021-06-21
  • 2021-07-27
  • 2022-02-12
  • 2021-11-25
  • 2022-01-07
  • 2022-01-21
  • 2021-08-11
相关资源
相似解决方案