Получить данные из openweathermap.org с помощью getJSON - PullRequest
0 голосов
/ 10 апреля 2020

Я пытаюсь получить данные с openweathermap.org с помощью функции jQuery get JSON, но есть некоторая проблема

var apiKey = "54df40e238084fbf095d3540271e48a0";
var URL = "api.openweathermap.org/data/2.5/weather?q=London&appid=" + apiKey;

$(document).ready(function() {

  $.getJSON(URL, function(data) {
    console.log(data);
  })


});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

1 Ответ

0 голосов
/ 10 апреля 2020

URL неверный, вам нужно сделать что-то вроде этого.

var apiKey = "54df40e238084fbf095d3540271e48a0";
var URL = "https://api.openweathermap.org/data/2.5/weather?q=London&appid="+apiKey;

$(document).ready(function(){

$.getJSON(URL,function(data){
    console.log(data);
})
});

Надеюсь, это поможет.

...