When I include aurelia-fetch-client in my project, I get some errors that I can't resolve. It says that it can't find: Request, Response, Headers, BufferSource, URLSearchParams, as you can see in the following image:
How can I solve that?
Add the typescript definition file for whatwg-fetch:
https://github.com/borisyankov/DefinitelyTyped/blob/master/whatwg-fetch/whatwg-fetch.d.ts
Here's more info on the fetch spec:
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
It's possible use typings
to install the whatwg-fetch types.
npm install typings --global
typings install dt~whatwg-fetch --global
The above installs them from DefinitelyTyped (dt
).
npm install --save @types/whatwg-fetch
Note: TypeScript might still complain that it "Cannot find name 'URLSearchParams'." We can fix that by adding the an interface to one of our typings files. For instance:
custom_typings/adhoc_interfaces.d.ts
interface URLSearchParams {}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With