Home>
Unable to interact with openweather api, inserting latitude and longitude values, writes wrong latitude. Moreover, if you write the latitude and longitude in numbers, everything works, the latitude and longitude are also determined correctly, I will attach a screen below.
ymaps.ready(locationPub);
function locationPub() {
var geolocation= ymaps.geolocation,
coords= [geolocation.latitude, geolocation.longitude];
let latt= [geolocation.latitude]
let lonl= [geolocation.longitude]
fetch("http://api.openweathermap.org/data/2.5/weather?lat={latt}&
lon={lonl}&
appid=2bd27f8ac9131b3542b76fd4f604fd73")
.then(function(resp) {
return resp.json()
})
.then(function(data) {
console log(data);
})
console log(latt)
console log(lonl)
}
Can someone tell me what I'm doing wrong?
fetch(http://api.openweathermap.org/data/2.5/weather?lat={latt}&lon={lonl}&appid=2bd27f8ac9131b3542b76fd4f604fd73) Did this, nothing changed(
sxndwl2022-02-12 22:18:14I did not say to completely remove the quotes, but to replace them with backticks. Do you catch the difference?
Bulson2022-02-12 22:18:14I copied it wrong, I'm sorry, everything worked out, thank you very much!
sxndwl2022-02-12 22:18:14-
Answer # 1
The problem was double quotes, you should have used "backticks"(``) I will attach the result below.
Trends
- python - you may need to restart the kernel to use updated packages error
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- javascript - how to check if an element exists in puppeteer
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file
- i want to check the type of a shell script variable
- i want to call a child component method from a parent in vuejs
Not double quotes, but backticks (where the tilde key is) must be used.
Bulson2022-02-12 22:18:14