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

FetchServer No headers on Response object #33

Closed
tsubik opened this issue Dec 14, 2020 · 1 comment
Closed

FetchServer No headers on Response object #33

tsubik opened this issue Dec 14, 2020 · 1 comment

Comments

@tsubik
Copy link

tsubik commented Dec 14, 2020

I noticed that headers are somehow not passed to Response object.

I have a simple setup like this

const restServer = new FakeRest.FetchServer('http://localhost:3000');
restServer.toggleLogging();
restServer.init(data);
restServer.addResponseInterceptor(function (response) {
  console.log('Response interceptor', response);
  return response;
});
fetchMock.mock('begin:http://localhost:3000', restServer.getHandler());


// and somewhere in the code
fetch('http://localhost:3000/scans?' + queryString, { headers })
    .then(res => {
      console.log('fetch response headers', res.headers);
    });

FetchServer log shows correct headers.

image

I tried with fetchMock version 5 and the newest 9, same results.

Tested on Chrome and Firefox.

@tsubik
Copy link
Author

tsubik commented Dec 15, 2020

Nevermind, Headers are not showing properties like any other simple object. I should use get method to get header property. My bad, closing this.

@tsubik tsubik closed this as completed Dec 15, 2020
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

1 participant