There are two functions; function getThumbnail(url) {} and function getVimeoData() {}.
I'm using fetch() to handle the HTTP calls for retrieving the url of thumbnail of a video in Vimeo. oEmbed is used to fetch JSON data of a video, which contains thumbnail_url.
The functions goes as follow:
async function getVimeoThumb(videoUrl) {
return await fetch(videoUrl)
.then(response => {
if (response.status !== 200) {
console.log('Error occurred while fetching thumbnail.');
return null;
}
return response.json();
})
.then(data => {return data['thumbnail_url']})
.catch(err => console.log(err.reason));
}
The above function returns Promise with a value [[PromiseValue]]: "{{thumbnail_url}}". The returned Promise value is fetched in following function as:
function getThumbnailUrl() {
let newUrl;
...
getVimeoThumb(url).then(result => {console.log(result)})
...
}
The above function returns console log as {{thumbnail_url}}.
Hence, my question is that is there any workaround to store the fetched value {{thumbnail_url}} in my local variable newUrl?