How to create an API Client with endpoints in a React Application?

By | July 14, 2018
Questions:

I’m creating my first Public React Application, but I’m facing a problem.

I have a back-end server, in which I request/send a lot of data through my React App.

How to create an endpoint client so that I can change the host (http://localhost:8000 or http://foo.com) and values (userId or commentId) constantly without having to edit them one by one?

How is this problem solved by large projects?

Is there a Rest API Client that helps me to write my endpoints, being able to prepend the API Host and join the values into a full URL? Like this:

/users/{id} -> https://localhost:8000/users/1

Answers:

Leave a Reply

Your email address will not be published. Required fields are marked *