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.

function locationPub() {
  var geolocation= ymaps.geolocation,
    coords= [geolocation.latitude, geolocation.longitude];
  let latt= [geolocation.latitude]
  let lonl= [geolocation.longitude]
    .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?

Not double quotes, but backticks (where the tilde key is) must be used.

Bulson2022-02-12 22:18:14

fetch(http://api.openweathermap.org/data/2.5/weather?lat={latt}&lon={lonl}&appid=2bd27f8ac9131b3542b76fd4f604fd73) Did this, nothing changed(

sxndwl2022-02-12 22:18:14

I did not say to completely remove the quotes, but to replace them with backticks. Do you catch the difference?

Bulson2022-02-12 22:18:14

I 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.