0
Hello guys I’m trying to do this, but unsuccessfully:
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<section id="lista-filmes"></section>
</body>
</html>
Jquery:
var filmes = [];
$.get("https://www.mocky.io/v2/5ad631b32e00001000c93a96", function(data){
data.forEach(function(filme){
filmes.push(filme);
});
});
$.get(`http://www.omdbapi.com/?i=tt0108037&apikey=???`,function(data){
});
console.log(filmes[0]);
The values I receive are undefined
the idea is, when I consequent accumulate in an array the request, I pass to the second url
for(etc.) {
$.get(`http://www.omdbapi.com/?i=${filmes[i]}&apikey=???`,function(data)
});
}
do something like, to be able to consume the second api.
You can’t because the first request is asynchronous.
– Sam
how do I reverse this? what should I study?
– Nicolas Guilherme Matheus