contentful.js
contentful.js copied to clipboard
Fetch support
If I am not mistaken your library is using axios
is it possible to have support for fetch
API?
Thanks
Hey @MatteoGioioso, any reason you want to use fetch instead of axios?
@Khaledgarbaya I think it might be better for service worker
support
@Khaledgarbaya I am not able to use contentful.js
on a Cloudflare worker since it uses axios. Axios does not work there and fetch()
must be used instead.
@Khaledgarbaya
axios
support doesn't look too good (I would even say quite bad), despite it being "all-time awesome library".
This has been raised by many people externally and as issue on axios
issue page, see following https://github.com/axios/axios/issues/1965.
Of course there are alternatives like https://github.com/googleapis/gaxios, but that just takes focus away from root problem:
-
contentful.js
library should not force to use one and only http library but rather suggest it and provide API to inject custom http library, either it'sfetch
,axios
,gaxios
or whatever will become popular in 2020. -
axios
not being maintained/supported - yields more and more security issues overtime Please consider this as a fair warning and reasonable concern. Thank you!
in general there should be a way to customize which library one wants to use. some simple adapter for each library can be easily written, I for one would love to get it working with https://github.com/sindresorhus/got
I also prefer fetch
since its implemented in web, worker and deno.
I agree to @mendrik that contentful.js should use adapters. Axios should be one adapter and part of a separate package, then other adapters for fetch, or other http-clients, could easily be written.
This ticket has been closed due to inactivity. If you still need help resolving your issue, please reach out through our community Slack, or contact Contentful support directly.