質問編集履歴

1

エラー詳細を追加

2019/02/19 06:32

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -2,14 +2,48 @@
2
2
 
3
3
 
4
4
 
5
- ```url
6
-
7
- //Twitter Developerのサンプル
5
+ > //Twitter Developerのサンプル
8
6
 
9
7
  https://publish.twitter.com/oembed?url=https%3A%2F%2Ftwitter.com%2FInterior%2Fstatus%2F507185938620219395
10
-
11
- ```
12
8
 
13
9
 
14
10
 
15
11
  上記urlにアクセスしてjsonデータは取得できたのですが、これをfetchAPIを使ってページに出力する方法がわかりません。
12
+
13
+
14
+
15
+ 試しに
16
+
17
+ ```JavaScript
18
+
19
+ function (){
20
+
21
+ var url = 'https://publish.twitter.com/oembed?url=https%3A%2F%2Ftwitter.com%2FInterior%2Fstatus%2F507185938620219395';
22
+
23
+ fetch(url).then(function(response) {
24
+
25
+ console.log(response);
26
+
27
+ return response();
28
+
29
+ }).then(function(json) {
30
+
31
+ console.log(json);
32
+
33
+ });
34
+
35
+ }
36
+
37
+ ```
38
+
39
+ と書いてみたのですが、
40
+
41
+ > 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.
42
+
43
+
44
+
45
+ > Uncaught (in promise) TypeError: Failed to fetch
46
+
47
+
48
+
49
+ というエラーが出てしまいます。