request / request-promise

The simplified HTTP request client 'request' with Promise support. Powered by Bluebird.
ISC License
4.77k stars 297 forks source link

followRedirect question #332

Closed azhi09 closed 1 year ago

azhi09 commented 4 years ago

I write a login script with request-promie, and want to get a "location" value in response.header

when i write as below with right params(right username and password), i can get the date i want (res.header.location) in rp().catch(res => res.header.location)

result = await rp({
            url: url,
            method: "POST",
            headers,
            body: qs.stringify(params),
            followRedirect: false,
            resolveWithFullResponse: true
        })

when i write as below with wrong params(wrong username or password), i can not anything because no method be called(neithor rp().then() or re().catch() was be call, re().finaly() isnot work ).

result = await rp({
            url: url,
            method: "POST",
            headers,
            body: qs.stringify(params),
            followRedirect: false,
            resolveWithFullResponse: true
        })

i want to do something when i get the wrong params, how can i catch it.