node-request

pass JSON to HTTP POST Request

蓝咒 提交于 2019-12-17 07:04:10
问题 I'm trying to make a HTTP POST request to the google QPX Express API [1] using nodejs and request [2]. My code looks as follows: // create http request client to consume the QPX API var request = require("request") // JSON to be passed to the QPX Express API var requestData = { "request": { "slice": [ { "origin": "ZRH", "destination": "DUS", "date": "2014-12-02" } ], "passengers": { "adultCount": 1, "infantInLapCount": 0, "infantInSeatCount": 0, "childCount": 0, "seniorCount": 0 }, "solutions

Using nodejs server with request package and function pipe()?

匆匆过客 提交于 2019-12-12 20:40:11
问题 I'm using a nodejs server to mockup a backend at the moment. The server is a webserver and returns json objects on different requests, works flawlessy. Now I have to get the json objects from another domain, so I have to proxy the server. I have found a package called request in npm. I can get the simple example to work, but I have to forward the whole webpage. My code for the proxy looks like this: var $express = require('express'), $http = require('http'), $request = require('request'),

NodeJS Request returning an empty array inside a JSON response

蹲街弑〆低调 提交于 2019-12-11 14:08:02
问题 I am sending a POST JSON request to a URL and it is returning a JSON response. However, the array inside the JSON response is just returning [Object] instead of the Array of JSON elements it should be returning. Why is this happening? Ths is my code var request = require('request'); var requestData = { "AERequest":{ "serviceType":"BE", "deviceId": "Test", "accountId": "100008288964" } }; const url = "https://ibluatapig.indusind.com/app/uat/balinq/AccountEnquiry?client_id=6867b781-9b21-45c5

Check app running on new port

你说的曾经没有我的故事 提交于 2019-12-11 03:26:48
问题 I need to create application which get request for specific port and proxy it to new server on different port for example the following port 3000 will be proxy to port 9000 and you actually run the application on 9000 ( under the hood) since the user in the client click on 3000 http://localhost:3000/a/b/c http://localhost:9000/a/b/c I try something like var proxy = httpProxy.createProxyServer({}); http.createServer(function (req, res) { var hostname = req.headers.host.split(":")[0]; var

document is not defined when attempting to setState from the return of an async call in componentWillMount

前提是你 提交于 2019-12-09 14:54:47
问题 I grab my data in my componentWillMount call of my component [actually it's in a mixin, but same idea]. After the ajax call returns, I attempt to setState, but I get the error that the document is not defined. I'm not sure how to get around this. Is there something to wait for? A promise, or callback I should be doing the setState in? This is what I'm trying to do: componentWillMount: function() { request.get(this.fullUrl()).end(function(err, res) { this.setState({data: res.body}); }.bind

Streaming an uploaded file to an HTTP request

时光总嘲笑我的痴心妄想 提交于 2019-12-08 15:17:32
My goal is to accept an uploaded file and stream it to Wistia using the the Wistia Upload API . I need to be able to add fields to the HTTP request, and I don't want the file to touch the disk. I'm using Node , Express , Request , and Busboy . The code below has two console.log statements. The first returns [Error: not implemented] and the second returns [Error: form-data: not implemented] . I'm new to streaming in Node, so I'm probably doing something fundamentally wrong. Any help would be much appreciated. app.use("/upload", function(req, res, next) { var writeStream = new stream.Writable();

Node JS callbacks with Alexa skill

夙愿已清 提交于 2019-12-07 15:27:48
问题 I have a module that includes a request call, which doesn't appear to be getting executed. var request = require('request'); var Alexa = require('alexa-sdk'); var APP_ID = <my alexa app ID>; var self = module.exports = { handler : function (event, context, callback) { var alexa = Alexa.handler(event, context); alexa.appId = APP_ID; alexa.registerHandlers(self); alexa.execute(); }, "TestIntent": function () { var speechOutput = "Recorded Test"; request("http://www.google.com", function(error,

Trouble with posting JSON data (with node request) to Express server for saving into MongoDB

时间秒杀一切 提交于 2019-12-02 16:38:03
问题 I use MongoDB as the back-end database for my node/Express application. To summarize the problem I am facing, I don't know how to set up the body-parser configuration in my Express app, because the server side application is not receiving the full JSON posted by the client application (also a node.js app). For the most part, the client is sending JSON in the request body to RESTful endpoints. The exception being a single case where a file needs to be uploaded and since that is a multipart

Trouble with posting JSON data (with node request) to Express server for saving into MongoDB

时光怂恿深爱的人放手 提交于 2019-12-02 10:05:25
I use MongoDB as the back-end database for my node/Express application. To summarize the problem I am facing, I don't know how to set up the body-parser configuration in my Express app, because the server side application is not receiving the full JSON posted by the client application (also a node.js app). For the most part, the client is sending JSON in the request body to RESTful endpoints. The exception being a single case where a file needs to be uploaded and since that is a multipart body, I am using request and form-data to build that type of request and using multer on the server side

Why doesn't request.on() work in Node.js

青春壹個敷衍的年華 提交于 2019-12-01 12:44:51
I'm trying to get some data from a third party service using the node request module and return this data as string from a function. My perception was that request() returns a readable stream since you can do request(...).pipe(writeableStream) which - I thought - implies that I can do function getData(){ var string; request('someurl') .on('data', function(data){ string += data; }) .on('end', function(){ return string; }); } but this does not really work. I think I have some wrong perception of how request() or node streams really work. Can somebody clear up my confusion here? It does work