Open Weather Api (Show weather icon)












-1















Hello community back to you again. I am playing with the openweather API and i am building a simple weather app. I have an issue and i can't show the weather conditions icon for each city.



I pushed every icon id in a newArray and i am trying to show it using the url but without luck http://openweathermap.org/img/w/10d.png



Any suggestion?Thanks in advance






var app = new Vue({
el: "#app",
data: {

test: ,
image: ,
newArray:,
message: "",
url: "",

},
created: function () {
this.getData();
this.cities();

},
methods: {
getData: function () {
var fetchConfig =
fetch("https://api.myjson.com/bins/i8run", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.test = json.list;
console.log(app.test);
app.pushAnArr();


})
.catch(function (error) {
console.log(error);
})
},

cities: function () {
var fetchConfig =
fetch("https://pixabay.com/api/?key=10772849-8270b213e517e422b036ea0fd&q=city", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.image = json.hits;
console.log(app.image);


})
.catch(function (error) {
console.log(error);
})
},

pushAnArr: function(){
for(var i=0; i<app.test.length; i++){

app.newArray.push(app.test[i].weather[0].icon);


}
console.log(app.newArray);


}


}
})


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="app">
<div v-for="item in newArray" :key="item.id" class="thecard">
{{item}}
<img src="http://openweathermap.org/img/w/item.png" >
</div>

</div>





<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="main.js"></script>
</body>
</html>












share|improve this question























  • You are using the static URL http://openweathermap.org/img/w/item.png every single time. Maybe you want to put your {{item}} placeholder in there somewhere as well …?

    – misorude
    Nov 26 '18 at 8:52













  • You're definitely trying to show src="openweathermap.org/img/w/item.png", aren't you?

    – Gino Pane
    Nov 26 '18 at 8:53
















-1















Hello community back to you again. I am playing with the openweather API and i am building a simple weather app. I have an issue and i can't show the weather conditions icon for each city.



I pushed every icon id in a newArray and i am trying to show it using the url but without luck http://openweathermap.org/img/w/10d.png



Any suggestion?Thanks in advance






var app = new Vue({
el: "#app",
data: {

test: ,
image: ,
newArray:,
message: "",
url: "",

},
created: function () {
this.getData();
this.cities();

},
methods: {
getData: function () {
var fetchConfig =
fetch("https://api.myjson.com/bins/i8run", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.test = json.list;
console.log(app.test);
app.pushAnArr();


})
.catch(function (error) {
console.log(error);
})
},

cities: function () {
var fetchConfig =
fetch("https://pixabay.com/api/?key=10772849-8270b213e517e422b036ea0fd&q=city", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.image = json.hits;
console.log(app.image);


})
.catch(function (error) {
console.log(error);
})
},

pushAnArr: function(){
for(var i=0; i<app.test.length; i++){

app.newArray.push(app.test[i].weather[0].icon);


}
console.log(app.newArray);


}


}
})


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="app">
<div v-for="item in newArray" :key="item.id" class="thecard">
{{item}}
<img src="http://openweathermap.org/img/w/item.png" >
</div>

</div>





<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="main.js"></script>
</body>
</html>












share|improve this question























  • You are using the static URL http://openweathermap.org/img/w/item.png every single time. Maybe you want to put your {{item}} placeholder in there somewhere as well …?

    – misorude
    Nov 26 '18 at 8:52













  • You're definitely trying to show src="openweathermap.org/img/w/item.png", aren't you?

    – Gino Pane
    Nov 26 '18 at 8:53














-1












-1








-1








Hello community back to you again. I am playing with the openweather API and i am building a simple weather app. I have an issue and i can't show the weather conditions icon for each city.



I pushed every icon id in a newArray and i am trying to show it using the url but without luck http://openweathermap.org/img/w/10d.png



Any suggestion?Thanks in advance






var app = new Vue({
el: "#app",
data: {

test: ,
image: ,
newArray:,
message: "",
url: "",

},
created: function () {
this.getData();
this.cities();

},
methods: {
getData: function () {
var fetchConfig =
fetch("https://api.myjson.com/bins/i8run", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.test = json.list;
console.log(app.test);
app.pushAnArr();


})
.catch(function (error) {
console.log(error);
})
},

cities: function () {
var fetchConfig =
fetch("https://pixabay.com/api/?key=10772849-8270b213e517e422b036ea0fd&q=city", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.image = json.hits;
console.log(app.image);


})
.catch(function (error) {
console.log(error);
})
},

pushAnArr: function(){
for(var i=0; i<app.test.length; i++){

app.newArray.push(app.test[i].weather[0].icon);


}
console.log(app.newArray);


}


}
})


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="app">
<div v-for="item in newArray" :key="item.id" class="thecard">
{{item}}
<img src="http://openweathermap.org/img/w/item.png" >
</div>

</div>





<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="main.js"></script>
</body>
</html>












share|improve this question














Hello community back to you again. I am playing with the openweather API and i am building a simple weather app. I have an issue and i can't show the weather conditions icon for each city.



I pushed every icon id in a newArray and i am trying to show it using the url but without luck http://openweathermap.org/img/w/10d.png



Any suggestion?Thanks in advance






var app = new Vue({
el: "#app",
data: {

test: ,
image: ,
newArray:,
message: "",
url: "",

},
created: function () {
this.getData();
this.cities();

},
methods: {
getData: function () {
var fetchConfig =
fetch("https://api.myjson.com/bins/i8run", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.test = json.list;
console.log(app.test);
app.pushAnArr();


})
.catch(function (error) {
console.log(error);
})
},

cities: function () {
var fetchConfig =
fetch("https://pixabay.com/api/?key=10772849-8270b213e517e422b036ea0fd&q=city", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.image = json.hits;
console.log(app.image);


})
.catch(function (error) {
console.log(error);
})
},

pushAnArr: function(){
for(var i=0; i<app.test.length; i++){

app.newArray.push(app.test[i].weather[0].icon);


}
console.log(app.newArray);


}


}
})


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="app">
<div v-for="item in newArray" :key="item.id" class="thecard">
{{item}}
<img src="http://openweathermap.org/img/w/item.png" >
</div>

</div>





<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="main.js"></script>
</body>
</html>








var app = new Vue({
el: "#app",
data: {

test: ,
image: ,
newArray:,
message: "",
url: "",

},
created: function () {
this.getData();
this.cities();

},
methods: {
getData: function () {
var fetchConfig =
fetch("https://api.myjson.com/bins/i8run", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.test = json.list;
console.log(app.test);
app.pushAnArr();


})
.catch(function (error) {
console.log(error);
})
},

cities: function () {
var fetchConfig =
fetch("https://pixabay.com/api/?key=10772849-8270b213e517e422b036ea0fd&q=city", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.image = json.hits;
console.log(app.image);


})
.catch(function (error) {
console.log(error);
})
},

pushAnArr: function(){
for(var i=0; i<app.test.length; i++){

app.newArray.push(app.test[i].weather[0].icon);


}
console.log(app.newArray);


}


}
})


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="app">
<div v-for="item in newArray" :key="item.id" class="thecard">
{{item}}
<img src="http://openweathermap.org/img/w/item.png" >
</div>

</div>





<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="main.js"></script>
</body>
</html>





var app = new Vue({
el: "#app",
data: {

test: ,
image: ,
newArray:,
message: "",
url: "",

},
created: function () {
this.getData();
this.cities();

},
methods: {
getData: function () {
var fetchConfig =
fetch("https://api.myjson.com/bins/i8run", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.test = json.list;
console.log(app.test);
app.pushAnArr();


})
.catch(function (error) {
console.log(error);
})
},

cities: function () {
var fetchConfig =
fetch("https://pixabay.com/api/?key=10772849-8270b213e517e422b036ea0fd&q=city", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.image = json.hits;
console.log(app.image);


})
.catch(function (error) {
console.log(error);
})
},

pushAnArr: function(){
for(var i=0; i<app.test.length; i++){

app.newArray.push(app.test[i].weather[0].icon);


}
console.log(app.newArray);


}


}
})


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="app">
<div v-for="item in newArray" :key="item.id" class="thecard">
{{item}}
<img src="http://openweathermap.org/img/w/item.png" >
</div>

</div>





<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="main.js"></script>
</body>
</html>






javascript html css api weather






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 26 '18 at 8:47









Ioan DimiIoan Dimi

547




547













  • You are using the static URL http://openweathermap.org/img/w/item.png every single time. Maybe you want to put your {{item}} placeholder in there somewhere as well …?

    – misorude
    Nov 26 '18 at 8:52













  • You're definitely trying to show src="openweathermap.org/img/w/item.png", aren't you?

    – Gino Pane
    Nov 26 '18 at 8:53



















  • You are using the static URL http://openweathermap.org/img/w/item.png every single time. Maybe you want to put your {{item}} placeholder in there somewhere as well …?

    – misorude
    Nov 26 '18 at 8:52













  • You're definitely trying to show src="openweathermap.org/img/w/item.png", aren't you?

    – Gino Pane
    Nov 26 '18 at 8:53

















You are using the static URL http://openweathermap.org/img/w/item.png every single time. Maybe you want to put your {{item}} placeholder in there somewhere as well …?

– misorude
Nov 26 '18 at 8:52







You are using the static URL http://openweathermap.org/img/w/item.png every single time. Maybe you want to put your {{item}} placeholder in there somewhere as well …?

– misorude
Nov 26 '18 at 8:52















You're definitely trying to show src="openweathermap.org/img/w/item.png", aren't you?

– Gino Pane
Nov 26 '18 at 8:53





You're definitely trying to show src="openweathermap.org/img/w/item.png", aren't you?

– Gino Pane
Nov 26 '18 at 8:53












1 Answer
1






active

oldest

votes


















1














You can't use curlies {{item}} in attributes.



Use:



<img v-bind:src="'http://openweathermap.org/img/w/' + item + '.png' "  />





var app = new Vue({
el: "#app",
data: {

test: ,
image: ,
newArray:,
message: "",
url: "",

},
created: function () {
this.getData();
this.cities();

},
methods: {
getData: function () {
var fetchConfig =
fetch("https://api.myjson.com/bins/i8run", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.test = json.list;
console.log(app.test);
app.pushAnArr();


})
.catch(function (error) {
console.log(error);
})
},

cities: function () {
var fetchConfig =
fetch("https://pixabay.com/api/?key=10772849-8270b213e517e422b036ea0fd&q=city", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.image = json.hits;
console.log(app.image);


})
.catch(function (error) {
console.log(error);
})
},

pushAnArr: function(){
for(var i=0; i<app.test.length; i++){

app.newArray.push(app.test[i].weather[0].icon);


}
console.log(app.newArray);


}


}
})


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="app">
<div v-for="item in newArray" :key="item.id" class="thecard">
{{item}}
<img v-bind:src="'http://openweathermap.org/img/w/' + item + '.png' " />
</div>

</div>





<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="main.js"></script>
</body>
</html>








share|improve this answer
























  • Thank you very very much . I didn't use {{}} in my code was just a kind of testing ,your solution works. :) :)

    – Ioan Dimi
    Nov 26 '18 at 12:04











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53477427%2fopen-weather-api-show-weather-icon%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You can't use curlies {{item}} in attributes.



Use:



<img v-bind:src="'http://openweathermap.org/img/w/' + item + '.png' "  />





var app = new Vue({
el: "#app",
data: {

test: ,
image: ,
newArray:,
message: "",
url: "",

},
created: function () {
this.getData();
this.cities();

},
methods: {
getData: function () {
var fetchConfig =
fetch("https://api.myjson.com/bins/i8run", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.test = json.list;
console.log(app.test);
app.pushAnArr();


})
.catch(function (error) {
console.log(error);
})
},

cities: function () {
var fetchConfig =
fetch("https://pixabay.com/api/?key=10772849-8270b213e517e422b036ea0fd&q=city", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.image = json.hits;
console.log(app.image);


})
.catch(function (error) {
console.log(error);
})
},

pushAnArr: function(){
for(var i=0; i<app.test.length; i++){

app.newArray.push(app.test[i].weather[0].icon);


}
console.log(app.newArray);


}


}
})


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="app">
<div v-for="item in newArray" :key="item.id" class="thecard">
{{item}}
<img v-bind:src="'http://openweathermap.org/img/w/' + item + '.png' " />
</div>

</div>





<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="main.js"></script>
</body>
</html>








share|improve this answer
























  • Thank you very very much . I didn't use {{}} in my code was just a kind of testing ,your solution works. :) :)

    – Ioan Dimi
    Nov 26 '18 at 12:04
















1














You can't use curlies {{item}} in attributes.



Use:



<img v-bind:src="'http://openweathermap.org/img/w/' + item + '.png' "  />





var app = new Vue({
el: "#app",
data: {

test: ,
image: ,
newArray:,
message: "",
url: "",

},
created: function () {
this.getData();
this.cities();

},
methods: {
getData: function () {
var fetchConfig =
fetch("https://api.myjson.com/bins/i8run", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.test = json.list;
console.log(app.test);
app.pushAnArr();


})
.catch(function (error) {
console.log(error);
})
},

cities: function () {
var fetchConfig =
fetch("https://pixabay.com/api/?key=10772849-8270b213e517e422b036ea0fd&q=city", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.image = json.hits;
console.log(app.image);


})
.catch(function (error) {
console.log(error);
})
},

pushAnArr: function(){
for(var i=0; i<app.test.length; i++){

app.newArray.push(app.test[i].weather[0].icon);


}
console.log(app.newArray);


}


}
})


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="app">
<div v-for="item in newArray" :key="item.id" class="thecard">
{{item}}
<img v-bind:src="'http://openweathermap.org/img/w/' + item + '.png' " />
</div>

</div>





<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="main.js"></script>
</body>
</html>








share|improve this answer
























  • Thank you very very much . I didn't use {{}} in my code was just a kind of testing ,your solution works. :) :)

    – Ioan Dimi
    Nov 26 '18 at 12:04














1












1








1







You can't use curlies {{item}} in attributes.



Use:



<img v-bind:src="'http://openweathermap.org/img/w/' + item + '.png' "  />





var app = new Vue({
el: "#app",
data: {

test: ,
image: ,
newArray:,
message: "",
url: "",

},
created: function () {
this.getData();
this.cities();

},
methods: {
getData: function () {
var fetchConfig =
fetch("https://api.myjson.com/bins/i8run", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.test = json.list;
console.log(app.test);
app.pushAnArr();


})
.catch(function (error) {
console.log(error);
})
},

cities: function () {
var fetchConfig =
fetch("https://pixabay.com/api/?key=10772849-8270b213e517e422b036ea0fd&q=city", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.image = json.hits;
console.log(app.image);


})
.catch(function (error) {
console.log(error);
})
},

pushAnArr: function(){
for(var i=0; i<app.test.length; i++){

app.newArray.push(app.test[i].weather[0].icon);


}
console.log(app.newArray);


}


}
})


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="app">
<div v-for="item in newArray" :key="item.id" class="thecard">
{{item}}
<img v-bind:src="'http://openweathermap.org/img/w/' + item + '.png' " />
</div>

</div>





<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="main.js"></script>
</body>
</html>








share|improve this answer













You can't use curlies {{item}} in attributes.



Use:



<img v-bind:src="'http://openweathermap.org/img/w/' + item + '.png' "  />





var app = new Vue({
el: "#app",
data: {

test: ,
image: ,
newArray:,
message: "",
url: "",

},
created: function () {
this.getData();
this.cities();

},
methods: {
getData: function () {
var fetchConfig =
fetch("https://api.myjson.com/bins/i8run", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.test = json.list;
console.log(app.test);
app.pushAnArr();


})
.catch(function (error) {
console.log(error);
})
},

cities: function () {
var fetchConfig =
fetch("https://pixabay.com/api/?key=10772849-8270b213e517e422b036ea0fd&q=city", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.image = json.hits;
console.log(app.image);


})
.catch(function (error) {
console.log(error);
})
},

pushAnArr: function(){
for(var i=0; i<app.test.length; i++){

app.newArray.push(app.test[i].weather[0].icon);


}
console.log(app.newArray);


}


}
})


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="app">
<div v-for="item in newArray" :key="item.id" class="thecard">
{{item}}
<img v-bind:src="'http://openweathermap.org/img/w/' + item + '.png' " />
</div>

</div>





<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="main.js"></script>
</body>
</html>








var app = new Vue({
el: "#app",
data: {

test: ,
image: ,
newArray:,
message: "",
url: "",

},
created: function () {
this.getData();
this.cities();

},
methods: {
getData: function () {
var fetchConfig =
fetch("https://api.myjson.com/bins/i8run", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.test = json.list;
console.log(app.test);
app.pushAnArr();


})
.catch(function (error) {
console.log(error);
})
},

cities: function () {
var fetchConfig =
fetch("https://pixabay.com/api/?key=10772849-8270b213e517e422b036ea0fd&q=city", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.image = json.hits;
console.log(app.image);


})
.catch(function (error) {
console.log(error);
})
},

pushAnArr: function(){
for(var i=0; i<app.test.length; i++){

app.newArray.push(app.test[i].weather[0].icon);


}
console.log(app.newArray);


}


}
})


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="app">
<div v-for="item in newArray" :key="item.id" class="thecard">
{{item}}
<img v-bind:src="'http://openweathermap.org/img/w/' + item + '.png' " />
</div>

</div>





<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="main.js"></script>
</body>
</html>





var app = new Vue({
el: "#app",
data: {

test: ,
image: ,
newArray:,
message: "",
url: "",

},
created: function () {
this.getData();
this.cities();

},
methods: {
getData: function () {
var fetchConfig =
fetch("https://api.myjson.com/bins/i8run", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.test = json.list;
console.log(app.test);
app.pushAnArr();


})
.catch(function (error) {
console.log(error);
})
},

cities: function () {
var fetchConfig =
fetch("https://pixabay.com/api/?key=10772849-8270b213e517e422b036ea0fd&q=city", {
method: "GET",
headers: new Headers({})
}).then(function (response) {
if (response.ok) {
return response.json();
}
}).then(function (json) {
console.log("My json", json)

app.image = json.hits;
console.log(app.image);


})
.catch(function (error) {
console.log(error);
})
},

pushAnArr: function(){
for(var i=0; i<app.test.length; i++){

app.newArray.push(app.test[i].weather[0].icon);


}
console.log(app.newArray);


}


}
})


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="app">
<div v-for="item in newArray" :key="item.id" class="thecard">
{{item}}
<img v-bind:src="'http://openweathermap.org/img/w/' + item + '.png' " />
</div>

</div>





<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="main.js"></script>
</body>
</html>






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 26 '18 at 9:01









Tamil Selvan CTamil Selvan C

14.5k93659




14.5k93659













  • Thank you very very much . I didn't use {{}} in my code was just a kind of testing ,your solution works. :) :)

    – Ioan Dimi
    Nov 26 '18 at 12:04



















  • Thank you very very much . I didn't use {{}} in my code was just a kind of testing ,your solution works. :) :)

    – Ioan Dimi
    Nov 26 '18 at 12:04

















Thank you very very much . I didn't use {{}} in my code was just a kind of testing ,your solution works. :) :)

– Ioan Dimi
Nov 26 '18 at 12:04





Thank you very very much . I didn't use {{}} in my code was just a kind of testing ,your solution works. :) :)

– Ioan Dimi
Nov 26 '18 at 12:04




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53477427%2fopen-weather-api-show-weather-icon%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin