I need to access a variable outside a java script node.js fetch function
€8-10 EUR
In Progress
Posted almost 5 years ago
€8-10 EUR
Paid on delivery
//Here's a simple example of my problem, I've been trying to solve it all morning but I just can't manage for the life of me, it has something to do with promises and local scope, like the code will keep running even if the function didn't complete it's task..
var testMe = "empty"
[login to view URL](testMe) // outputs "empty"
fetch(exampleInfo)
.then(function(response) {
return [login to view URL]()
})
.then(function(myJson) {
[login to view URL](myJson) // outputs "full"
testMe = myJson
[login to view URL](testMe) // outputs "full"
});
[login to view URL](testMe) // outputs "empty"
Hello , sir.
How are you?
I just saw your project description carefully.
I am very interested in your project.
I have already solved it.
I have rich experience in Web development.
I am a full time developer and can work for you for a long time.
I am ready to start your project immediately.
I am sure I can satisfy you surely and complete in a short time.
Please send your message so that we can discuss about your project.
I think you are not hiring. But, the problem here is that you are using fetch which is an asynchronous function. So, you have to wait async-await or callbacks. Text me for more info.
€8 EUR in 1 day
0.0 (0 reviews)
0.0
0.0
3 freelancers are bidding on average €9 EUR for this job