Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response URL #1467

Open
motiejuss opened this issue Mar 11, 2019 · 3 comments
Open

Response URL #1467

motiejuss opened this issue Mar 11, 2019 · 3 comments

Comments

@motiejuss
Copy link

Wasn't able to find how to get response URL: http://visionmedia.github.io/superagent/#response-properties. The use case is simple - I have a starting URL and I don't know the response URL, because of following redirects. Is this possible?

@mootari
Copy link

mootari commented Sep 7, 2019

You can access the current URL via response.request.url.

Edit: Clientside you may have to access response.xhr.responseURL.

@EmilienLeroy
Copy link

With supertest you can access to response location with response.header.location.
I think is the same with superagent.

For exemple with mocha + supertest :

const request = require('supertest');

it('Should redirect to the login page', async() => {
         const res = await request(app).get('/Dashboard');
         res.header.location.should.equals('/Dashboard/login');
});

@honestxll
Copy link

here is my solution

const response = await request.get('http://foo.com');
const url = response.redirects.pop();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants