React + http api calls

Hi,
What’s the best way to make an http API call from a react ionic app? I looked into axios but was having trouble getting it to work. Is there an example anywhere?

1 Like

Axios seems fine to me.

Most of the react documentation uses fetch.

See here: https://reactjs.org/docs/faq-ajax.html

Depending upon your setup you might find it easier to work with a stack like Firebase or amplify as they have decent documentation and are ready to roll with specific SDKs. Just a thought!

Thanks. And do you suggest I create an ionic service for the API call?

Yeah I would do something like that I guess.

This is something I found just off the top… https://stackoverflow.com/questions/46750263/react-js-how-to-do-service-layer-call

Seems like a reasonable approach…

Are you coming from the Angular world?

use reacthooks… https://dev.to/savagepixie/fetching-data-with-react-hooks-2mc5

1 Like

This is the best & quick tutorial to call rest API in ionic react application using Axios.