Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
295 views
in Technique[技术] by (71.8m points)

Deploy a React App with an API REST architecture to Heroku

I would like to host to Heroku a small project I was working which is a react app with a backend using Express. I'm calling an API (newsapi) directly with React to gather some news by source, language, country etc.. I'm using the CRUD operation then with the fetch method and it's working perfectly in local .

When I create and push the app on Heroku , the website is well hosted but the API seems to not be connected and the news by source and article are not read .

This is how I called the API on React:

const recentNews = async () => {
  let rawResponse = await fetch(
    `https://newsapi.org/v2/sources?language=${language}&country=${country}&apiKey=XXXX(edit)`
  );
  let response = await rawResponse.json();
  setsourceList(response.sources);

Any specific action to enter in the terminal to host it on Heroku?

Thanks.

question from:https://stackoverflow.com/questions/65644473/deploy-a-react-app-with-an-api-rest-architecture-to-heroku

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...