비슷한 주제를 많이 읽었지만 도움이되지 않았습니다 ..
이 JSON 개체에 액세스하려고합니다 ..
{
"coord": {
"lon": -83.9,
"lat": 33.99
},
"weather": [
{
"id": 701,
"main": "Mist",
"description": "mist",
"icon": "50n"......
이 스크립트로. jQuery CDN에 연결하여 내 API 키가 올바른지 확인했습니다.
<html>
<script
src="https://code.jquery.com/jquery-2.2.4.min.js"
integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
crossorigin="anonymous"></script>
<script>$(document).ready(function(){
var api = "http://api.openweathermap.org/data/2.5/weather?lat=33.9654688&lon=-83.9138728&appid=(This is where the apikey goes)";
$.getJSON(api, function(data){
console.log(api.weather.main);
});
});
</script>
</html>
어떤 도움이라도 대단히 감사합니다. 이것은 API 호출을 처음 수행하므로 지금 당장 큰 장애물입니다.
아마도 당신은 다음 data
과 같이 읽어야 console.log(data);
합니까?
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다