klaviyo-api-node icon indicating copy to clipboard operation
klaviyo-api-node copied to clipboard

Fetch API vs Axios

Open TheDunco opened this issue 2 years ago • 5 comments

Would it be possible for future versions of the API to use the standard fetch API instead of Axios? From what I've seen Axios is making the API more difficult to work with, as we don't get standard things like response.ok to check successes with.

Another issue is that the errors that come back from the API are nested deep within the {caught error/response}.response.data.errors object and it took me forever to realize that I was actually getting error data back. I'd at least like to see a generic KlaviyoApiError Type exported from the package so we know the shape of the error data that's coming back.

TheDunco avatar Sep 26 '23 15:09 TheDunco

Another reason to support fetch is Axios isn't supported on some runtimes such as Vercel serverless

- adapter xhr is not supported by the environment
- adapter http is not available in the build
    at new Promise (<anonymous>)```

pete183 avatar Oct 05 '23 09:10 pete183

Well this is klaviyo-api-node :P

pauldraper avatar Apr 26 '24 05:04 pauldraper

Vercel serverless functions execute a Node process: https://vercel.com/docs/functions/runtimes/node-js

charkour avatar Apr 26 '24 10:04 charkour

Yeah, maybe @pete183 is referring to Vercel Edge?

pauldraper avatar Apr 27 '24 04:04 pauldraper

The team is looking into switching to fetch.

Ian-Montgomery-Klaviyo avatar Aug 01 '24 18:08 Ian-Montgomery-Klaviyo