Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    John Doe
    I have
    import request from 'request-promise-native';
    creating a UMD module
    in the browser everything works fine
    when I get to NODE repl and inject my dist file
    TypeError: global.XMLHttpRequest is not a constructor
    This happens when I require my bundle ( using webpack)
    any ideas?
    John Doe
    ok I fixed that issue .. got new one ..
    Hi all. I'm having issues setting my content-type header for a request containing files.
    .then(token => {
        return rest.post({
            uri: '/api/v1/upload',
            headers: {
                'Authorization': token,
                'content-type': 'multipart/mixed',
            formData: formData
    the request still shows the value multipart/form-data
    am I setting the header wrong somehow?
    John Doe
    oook :)
    what do you want to upload ?
    Nicolai Kamenzky
    @pulkitsinghal Hey old pal, how are you doing? Have a look at the README. At the bottom there are all changes with the breaking changes being marked. At the top there are even migration steps you might need to take.
    Nicolai Kamenzky
    @andreasvirkus Have a look at the details about forms in the request README. Btw, all request options work for request-promise as well. Usually, you don’t have to set the header yourself. It’s set automatically when you e.g. use the formData option.
    Pulkit Singhal
    @analog-nico - you're right! i got distracted with the notes on top and didn't scroll down far enough to see the details at the bottom. Thanks for pointing that out!!!
    The curl equivalent of what I'm trying to accomplish is this:
    curl -X POST http://localhost:8080/api/v1/upload -H “authorization:here goes token"
      --header "Content-type: multipart/mixed"  -F "imageFile=@TestImage.jpg”
      -F "imageFile=@TestImage2.jpg" -F "applicationNumber=SL-ESA-17000322"   -F "personalId=12345678A"
    @analog-nico I can't use multipart/form-data unfortunately : /

    If I try and send my images as base64:

    const formData = {
        imageFile: files.map(file => new Buffer(fs.readFileSync(file.path)).toString('base64')),

    then I get an error write after end

    Correction, the error I get is about the request being sent with contentType multipart/form-data:
    415 - "{\"timestamp\":1506930784462,\"status\":415,\"error\":
    \"Unsupported Media Type\",\"exception\":\"org.springframework.web.HttpMediaTypeNotSupportedException\",
    \"message\":\"Content type 'multipart/form-data;boundary=--------------------------732586446978103238773917' not supported\",
    any help greatly appreciated!
    Any help?
    For any future lurkers, I figured it out. Ended up with this code:
    const formData = {
    const multipart = files.map(file => ({
        'content-type': 'multipart/mixed',
        body: fs.createReadStream(file.path),
    return rest.post({
        postambleCRLF: true,
        uri: Configuration.getIdentificationServiceUrl() + '/api/v1/upload',
        headers: {
            'Content-type': 'multipart/mixed',
            'Authorization': token,
        qs: formData,
    Has anyone heard of issues of promises losing their way when a request is sent to a proxy
    Hi all, I'm looking to use request-promise to send multiple messages to facebook (https://graph.facebook.com/v2.6/me/messages) in sequence. Could someone help out - although having read-up on simple promises, I'm not sure about chaining and catching errors.
    Velin Georgiev
    Hi all, does request-promise-native support sending requests behind corporate proxy?
    Dan Stein
    Hey, im getting unhandled rejection errors from request-promise
    but as far as im aware my .then chain is correct
    charlie kurban


    I have request promise version 2.83.0
    When I make a api call to the backend via request-promise then I am getting below written timeout error BUT when I make same call via POSTMAN then it works fine. Seems to be error is down to the request-promise.

    { RequestError: Error: connect ETIMEDOUT
    at new RequestError (/Users/xxx/dev/yyyy/node_modules/request-promise-core/lib/errors.js:14:15)
    at Request.plumbing.callback (/Users/xxx/dev/yyyy/node_modules/request-promise-core/lib/plumbing.js:87:29)
    at Request.RP$callback [as _callback] (/Users/xxx/dev/yyyy/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at self.callback (/Users/xxx/dev/yyyy/node_modules/request/request.js:186:22)
    at Request.emit (events.js:127:13)
    at Request.emit (domain.js:421:20)
    at Request.onRequestError (/Users/xxx/dev/yyyy/node_modules/request/request.js:878:8)
    at ClientRequest.emit (events.js:132:15)
    at ClientRequest.emit (domain.js:421:20)
    at TLSSocket.socketErrorListener (_http_client.js:394:9)
    at TLSSocket.emit (events.js:127:13)
    at TLSSocket.emit (domain.js:421:20)
    at emitErrorNT (internal/streams/destroy.js:64:8)
    at process._tickCallback (internal/process/next_tick.js:114:19)
    Hi, I want to use request-promise for fetching prices from a supplier site. My main concern is i need to log in before accessing all the prices
    So i have to maintain session after the login
    I tried to include cookies in each request with let j = request.jar()then adding jar : jin options of each request but it apparently doesn't works... Anyone has an idea of how to achieve that?
    what option I need to set for CA validation?
    for request-promise-native
    I'm using request-promise with a bearer token. I get back a "StatusCodeError: 404 - undefined" error. The same uri I'm using works in Postman. Do any of you know why I'm getting a 404 error?
    Daniel Payne
    im having a mem leak with the new tough cookie filling up the heap
    (node:19286) UnhandledPromiseRejectionWarning: StatusCodeError: 400 - {"error":{"message":"INVALID_PARAMETERS"}}
    .. I am having this error on my terminal while tryin to get a request and i have handled the promise well i think.. here it is.... createInvoices: (whose, payload) => {
    return new Promise((resolve, reject) => {
    .then(token => {
    var options = {
    url: config.api.invoices,
    method: "POST",
    json: true,
    headers: {
    authorization: Bearer ${token}
    body: payload
    rp(options).then(crtdinvoice => {
    // resolve(data)
                }) .catch(err => {
    Nicolai Kamenzky
    I think you are missing the catch for the promise returned by self.login(...)
    Lucas Kohorst

    Hi guys I am working on using react and corenlp for a project. corenlp depends on request-promise-native. When I start my react app I get an error ./node_modules/corenlp/dist/connector/connector-serer.js Module not found: Can't resolve 'request-promise-native'

    Even though I have request-promise-native in my package.json

    Hey, had a quick question
    when running mocha from CLI, all of the request-promise promises are logging out; its super annoying
    any way to suppress the logs?
    i understand it's a bit out of context question
    hello guys, i'm trying to upgrade my code and put a kind of tracker, like i'll receive de coord and use with API google maps, but this is happening
    let requestPromise = require ("request-promise"), this is de code that is doing this error