• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How can i get the actual results from this code

Resolved: How can i get the actual results from this code

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

When i console.log the output from getSpecificMonitorNews(url); i get the actual results. But when i use return await getSpecificMonitorNews(url);, the first results are overwritten by the last result received.

Answer:

newsContents is a global variable so its value changes. You’re returning a reference to that global object, not a copied version (and there’s no need to copy it if you just bring it inside the function).
So you can either move newsContents inside the function if you don’t need it elsewhere:
Or make a copy of the newsContents variable
Or just create a new object on the fly:

If you have better answer, please add a comment about this, thank you!

javascript
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Why when i change manualy the url on my react page it ignores the .css file?

24/03/2023

Resolved: navigate and redirect not redirecting to path in react router

24/03/2023

Resolved: Time Complexity: Find the number of people who know a secret leetcode 2327

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.