Skip to content

Instantly share code, notes, and snippets.

@yongfook
Created Oct 12, 2020
Embed
What would you like to do?
var videos = []
const res = await fetch("https://api.pexels.com/videos/search?query="+inputData.keyword+"&per_page=50&min_duration=5&max_duration=20", {
headers: { 'Authorization': inputData.pexels_api_key }
}).then(res => res.json())
.then(json => {
videos = json['videos'].filter(function (el) {
return el['duration'] >= 8 && el['duration'] <= 20
})
});
return {link: videos[Math.floor(Math.random() * videos.length)]['video_files'][0]['link']};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment