I'm trying to access the html response from axios and parse it using Cheerio then push it into my MongoDB. Problem is, when I want to use the response to update my database field, it's out of scope.I tried using a variable etc, but since it's asynchronous it's returning the value (Cheerio function) before getting the response and now my database has fields with null value.I have seen tutorials for using async/await but most of them are for react (front end)I realize I might have to do it all from scratch but is that necessary? Would it be possible to just change a few parts?My whole project is pretty huge so I am only putting one file from it, where I am doing this code so there might be some holes.Are there any resources I could use too?https://codesandbox.io/embed/elegant-hill-08qfh?fontsize=14&hidenavigation=1&theme=dark
Submitted February 15, 2020 at 08:32AM by pappermanfan
No comments:
Post a Comment