ツイートをblockquoteで埋め込むのではなく、ツイートのurlをjsで処理して表示したいです。
//Twitter Developerのサンプル
上記urlにアクセスしてjsonデータは取得できたのですが、これをfetchAPIを使ってページに出力する方法がわかりません。
試しに
JavaScript
1function (){ 2 var url = 'https://publish.twitter.com/oembed?url=https%3A%2F%2Ftwitter.com%2FInterior%2Fstatus%2F507185938620219395'; 3 fetch(url).then(function(response) { 4 console.log(response); 5 return response(); 6 }).then(function(json) { 7 console.log(json); 8 }); 9}
と書いてみたのですが、
Access to fetch at 'https://publish.twitter.com/oembed?url=https%3A%2F%2Ftwitter.com%2FInterior%2Fstatus%2F507185938620219395' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Uncaught (in promise) TypeError: Failed to fetch
というエラーが出てしまいます。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。