npm-request

How to download file over FTP in NodeJS?

只谈情不闲聊 提交于 2021-02-08 10:22:18
问题 I want to download file using absolute FTP URL, like ftp://host:port/dir/file.extension I've tried node-libcurl, wget, wget-improved, request . All failed saying that the protocol must be either HTTP or HTTPS. There are FTP clients available for Node (available on npmjs). But, as per their documentation, they require creating a connection to FTP Server, change directory and then download it. Is there any simple solution? 回答1: I will outline a simple approach here (and no complete solution

How to make an external api call within an AWS Lambda function

元气小坏坏 提交于 2020-06-11 05:20:30
问题 I'm having problem with a Lambda function which for some reason it goes on timeout . I tried to add some console.log to understand what was going on and everything works properly until the external http request . I use the npm module request I can see the log before the request, but the one inside the callback never shows up, like if the endpoint doesn't respond. Am I missing something? Thanks in advance! var mysql = require('mysql'); var request = require('request'); var config = require('.

Sending/handling GET requests in typescript using Express, Request and Node.js

本小妞迷上赌 提交于 2020-01-05 05:25:07
问题 I'm using a combination of Express and Request (installed using npm) to try to send a get request to get some json from the server. However no matter what I do the body that is returned is "undefined". This is the code in my server.js file. The json isn't actually what I'm sending, it's just an example as I can't post what I'm actually sending. import express = require("express"); import bodyParser = require("body-parser"); let app = express(); app.use(bodyParser.json()); app.get('/config',

Error: connect ETIMEDOUT when scraping

≡放荡痞女 提交于 2019-12-24 20:13:12
问题 I have a function that: 1. gets an array of 3000 'id' properties from mongoDB documents from collection foo . 2. Creates a GET request for each ID to get 'resp' obj for id, and stores it in another database. router.get('/', (req, res) => { var collection = db.get().collection('foo'); var collection2 = db.get().collection('test'); collection.distinct('id', (err, idArr) => { // count: 3000+ idArr.forEach(id => { let url = 'https://externalapi.io/id=' + id request(url, (error, response, body) =>

Node js for-loop wait for asynchronous function before next iteration?

坚强是说给别人听的谎言 提交于 2019-12-18 07:05:33
问题 I am making a function that refreshes data every so often and I am having issues with the request chain that I have. The problem is that I have a for-loop running the asynchronous requests and the for-loop will finish before the requests are done. setInterval(function(){ // this updates the total hours of all members every 10 seconds request({ // this gets all of the loyalty program members url: "",//omitted method: "GET" }, function(listError, listResponse, listBody) { if(listError == null &

How can I create a calendar event on Outlook with Microsoft Graph API?

老子叫甜甜 提交于 2019-12-12 18:45:51
问题 I have an app that integrates with Office365 and I am attempting to create a calendar event on an Outlook calendar using the Microsoft Graph API. Here is what I have so far: request.post({ url:'https://graph.microsoft.com/v1.0/me/events', form: { "Id": null, "Subject": "Discuss the Calendar REST API", "Body": { "ContentType": "Text", "Content": "This is some content." }, "Start": { "DateTime": "2016-01-24T18:00:00", "TimeZone": "Pacific Standard Time" }, "End": { "DateTime": "2016-01-25T19:00

How to wait a request response and return the value?

☆樱花仙子☆ 提交于 2019-12-06 13:58:28
问题 When I use a request module in node.js server, I have some problem such as wait and return. I would like to receive a "responseObject" value at requestController. To solve this problem, I have search the best way but I still do not find it. How can solve this problem? Thank in advance!! :) ========================================================================= var requestToServer = require('request'); function getRequest(requestObject) { var urlInformation = requestObject['urlInformation'];

How to wait a request response and return the value?

笑着哭i 提交于 2019-12-04 20:34:27
When I use a request module in node.js server, I have some problem such as wait and return. I would like to receive a "responseObject" value at requestController. To solve this problem, I have search the best way but I still do not find it. How can solve this problem? Thank in advance!! :) ========================================================================= var requestToServer = require('request'); function getRequest(requestObject) { var urlInformation = requestObject['urlInformation']; var headerInformation = requestObject['headerInformation']; var jsonObject = new Object( ); //

How to retrieve PayPal REST Api access-token using node

不打扰是莪最后的温柔 提交于 2019-12-04 15:09:12
问题 How to get the PayPal access-token needed to leverage the REST Api by using node? 回答1: Once you have a PayPal client Id and a Client Secret you can use the following: var request = require('request'); request.post({ uri: "https://api.sandbox.paypal.com/v1/oauth2/token", headers: { "Accept": "application/json", "Accept-Language": "en_US", "content-type": "application/x-www-form-urlencoded" }, auth: { 'user': '---your cliend ID---', 'pass': '---your client secret---', // 'sendImmediately':

npm WARN deprecated node-uuid@1.4.8: Use uuid module instead

牧云@^-^@ 提交于 2019-12-03 17:07:32
问题 When i try: $ npm install -g cordova@latest always get npm WARN deprecated node-uuid@1.4.8: Use uuid module instead mac Os Sierra 10.12 npm v. 4.4.4 node v. 6.10.2 Before install of cordova: $npm list -g node-uuid /usr/local/lib ....(empty) After: $npm list -g node-uuid /usr/local/lib ....cordova@6.5.0 ........cordova-lib@6.5.0 ............npm@2.15.12 ................request@2.74.0 ....................node-uuid@1.4.7 ............request@2.47.0 ................node-uuid@1.4.8 I tried follow