채택완료

제이쿼리 $getJson을 자바스크립트 fetch로 고칠려고합니다

Copy
let title_url = `https://www.youtube.com/watch?v=${nowurl}`
            $.getJSON('https://noembed.com/embed',
            {format: 'json', url: title_url}, function (data) { //를

//fetch(params).then 이렇게 바꾸고 싶은데 params에 어디까지 넣어야할까요?

 

 

|

답변 1개 / 댓글 1개

채택된 답변
+20 포인트

Copy
let title_url = `https://www.youtube.com/watch?v=${nowurl}`;
fetch('https://noembed.com/embed??' + new URLSearchParams({
    format: 'json',
    url: title_url,
}))
.then(function (response){
    return response.json();
})
.then(function (json){
    console.log(json);
});

답변에 대한 댓글 1개

답변을 작성하려면 로그인이 필요합니다.