0
votes

I have created react-js app using create-react-app tool And I have .net core web API When ever I'm calling web api i have to do something like fetch('localhost://7000/api/something') each time I want to avoid the repetitive use of 'localhost://7000' So Is there any way to configure react js app So that I can avoid this localhost string in every file whenever I'm utilizing web api?

1
Share us the code how you request web api.Edward

1 Answers

0
votes

For fetch, it accepts absolute url and relative url. But for relative url, it is according the base url for hosting create-react-app.

For a workaround, you may try define a variable to store the localhost://7000 and then reference it from fetch.