0

I am able to get the title of a youtube video without using and api key using the jQuery code below, how can I use ES6 fetch to do the same?

const vidurl = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';

$.getJSON('https://noembed.com/embed',
  {dataType: 'json', url: vidurl},  data => {
  console.log("JQUERY", data.title);
});
  • yes, that would be okay too, the example above is from https://stackoverflow.com/questions/30084140/youtube-video-title-with-api-v3-without-api-key http://jsbin.com/cufedixoju/edit?html,js,console,output – user2965653 Sep 27 '20 at 23:14

1 Answers1

8
const vidurl = 'https://www.youtube.com/watch?v=I_izvAbhExY';

fetch(`https://noembed.com/embed?dataType=json&url=${vidurl}`)
  .then(res => res.json())
  .then(data => console.log('fetch', data.title))
ΔO 'delta zero'
  • 3,506
  • 1
  • 19
  • 31