Link to home
Start Free TrialLog in
Avatar of Michael Sterling
Michael SterlingFlag for United States of America

asked on

New to React, new to APIs

I've created a react app and an API that I'm trying to make a call to through my react app. How do I do this? I'm doing this on my local machine (lap top). I'm using .Net Core 2.2 for my react app and .Net Core 3.1 for my API. What files or code other information can I / should I share to get the best help with this. I set up the React project right out of the box in Visual Studio 2019 as instructed by a basic tutorial. My API has been tested using swagger and it does work. Its very basic right now. User generated image
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

is your api service actually running?

Avatar of Michael Sterling

ASKER

Yes it is currently running.

You need to install an AJAX library like Axios that you can use to make calls to your API.


You can read more about it in the official docs here


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

From your screen shot it appears you are already using an AJAX library (confused by the what do I need to add to talk to an API question).


This thread seems to discuss this issue


https://github.com/swagger-api/swagger-ui/issues/3403


Several solutions suggested - one was concerning AWS not returning headers the other had to do with CORS not being setup correctly.


It is possible for your API's to work in a tool like Swagger or Postman and not work in the browser due to CORS not being set correctly - so you can check that.

ASKER CERTIFIED SOLUTION
Avatar of Michael Sterling
Michael Sterling
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial