Open zystudios opened 4 months ago
You can use the following code:
http
.get('http://example.com/')
// following redirects
.redirects(0)
// error handling
.ok(res => res.status >= 200 && res.status < 400)
.then(res => {
console.log(res.status)
console.log(res.headers['location'])
})
Reference documentation: Following Redirects: SuperAgent Documentation Error Handling: SuperAgent Documentation
You can use the following code:
http .get('http://example.com/') // following redirects .redirects(0) // error handling .ok(res => res.status >= 200 && res.status < 400) .then(res => { console.log(res.status) console.log(res.headers['location']) })
Reference documentation: Following Redirects: SuperAgent Documentation Error Handling: SuperAgent Documentation
thx, I'll try later
I request an API, this API will return 302, and automatically jump to another API, and then return data, but I see status code has been 200, I need to capture 302 to do some operations, what should I do?
thanks