contentful.js icon indicating copy to clipboard operation
contentful.js copied to clipboard

Fetch support

Open MatteoGioioso opened this issue 5 years ago • 7 comments

If I am not mistaken your library is using axios is it possible to have support for fetch API?

Thanks

MatteoGioioso avatar Jun 01 '19 09:06 MatteoGioioso

Hey @MatteoGioioso, any reason you want to use fetch instead of axios?

Khaledgarbaya avatar Jun 03 '19 07:06 Khaledgarbaya

@Khaledgarbaya I think it might be better for service worker support

MatteoGioioso avatar Aug 02 '19 03:08 MatteoGioioso

@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.

MickL avatar Dec 20 '19 10:12 MickL

@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's fetch, 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!

yevmoroz avatar Mar 06 '20 16:03 yevmoroz

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

mendrik avatar Mar 29 '21 18:03 mendrik

I also prefer fetch since its implemented in web, worker and deno.

wangzuo avatar Apr 14 '21 10:04 wangzuo

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.

MickL avatar Apr 14 '21 13:04 MickL

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.

mayakarabula avatar Jun 13 '23 15:06 mayakarabula