tsdexter
tsdexter

Reputation: 2991

Why does Edge not accept `undefined` in class instantiation but Chrome does? How do I fix?

Who is right? Chrome or Edge and how do I fix it? Do I need to change the webpack configuration to make it compensate for this issue?

See screenshots below - undefined is being passed to new Headers() Chrome doesn't care but Edge throws error invalid argument and crashes entire app

enter image description here

enter image description here

Upvotes: 0

Views: 274

Answers (1)

Matti Price
Matti Price

Reputation: 3551

Because IE (Edge is just dressed up IE, lets face it) is the bane of all our existences..

Just ensure the object you are passing isn't undefined. You can use javascripts truthy-ness to do this easily.

else {
    return new Headers(headers || {});
}

Looks like this is coming from Apollo-Link-Rest. Just create your RestLink like this instead

const restLink = new RestLink({
  uri: 'https://swapi.co/api/',
  headers: {},
});

Upvotes: 1

Related Questions