Reputation: 55
Since I'm new to API calls, I'm having issues regarding making API calls from backend. I've a form that takes AccessToken from the user. Based on the token received, I've to make an API call to 3rd party API. It should return the roles that the particular user has. The token has to be sent as headers. How to make the API call if the Frontend is on ReactJs and Backend is running on NodeJs.
Upvotes: 1
Views: 538
Reputation: 2033
Basically you have three entities at work here.
Assuming the flow of your application is like this:
Your Client -> (asks for some resource) Your Backend -> (requests an api from external service)
So you can expose an endpoint on Your Backend, which Your client will call and in turn Your Backend will call an External Service using a library like Axios or the inbuilt Fetch API. As soon as Your Backend gets a response from the External Service, you can send the received response to Your Client.
Hope it helps!
Upvotes: 2