I have a function that SHOULD get an IP-address and when found, return it. It doesn´t work: it doesn´t wait, ip-address comes back as undefined and function returns a promise. I am doing something wrong, but what? Anyone?
console.log(“ipadress after getting it=” + ipaddress);
return ipaddress;
}
}
The function returns a Promise, goes on with the next step, and after a while, at the very end, the console.log with the ip-address is logged, correctly, but too late.
Andreas, thanks, but, with minor changes (res/result) still not working. Still this function is not waiting, it kicks in after all is done (=too late).
the method by default is always GET, so you don’t need to set the method
call this kind of function and use DEV tools on your browser to extract from the objectIP whatever you need, since this is an object you can do objectIP.city or any other …