回答編集履歴

3

追記

2017/11/26 21:45

投稿

umyu
umyu

スコア5846

test CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ステータスコードが400(400 Bad Request)です。
6
6
 
7
- こういう場合は公式ドキュメントをまず確認します。
7
+ こういうは公式ドキュメントをまず確認します。
8
8
 
9
9
  [Pagespeedapi: runpagespeed](https://developers.google.com/speed/docs/insights/v2/reference/pagespeedapi/runpagespeed)
10
10
 
@@ -28,6 +28,8 @@
28
28
 
29
29
  &strategy=descktop
30
30
 
31
+
32
+
31
33
  &strategy=desktop
32
34
 
33
35
 

2

補足情報にFetch_APIを追記

2017/11/26 21:45

投稿

umyu
umyu

スコア5846

test CHANGED
@@ -8,7 +8,19 @@
8
8
 
9
9
  [Pagespeedapi: runpagespeed](https://developers.google.com/speed/docs/insights/v2/reference/pagespeedapi/runpagespeed)
10
10
 
11
+ >
11
12
 
13
+ >strategy string The analysis strategy to use
14
+
15
+ > Acceptable values are:
16
+
17
+ >  "desktop": Fetch and analyze the URL for desktop browsers
18
+
19
+ >  "mobile": Fetch and analyze the URL for mobile devices
20
+
21
+
22
+
23
+ 質問文で渡しているリクエストは以下です。
12
24
 
13
25
  > var requestA = 'https://www.googleapis.com/pagespeedonline/v2/runPagespeed?url=' + url + '&key=' + APIkey + '&strategy=descktop';
14
26
 
@@ -25,3 +37,7 @@
25
37
 
26
38
 
27
39
  Try this APIでAPIのテストを試せるのでそれも参考にしてください。
40
+
41
+ □補足情報
42
+
43
+ Chrome拡張でHTTPリクエストを投げる時はXMLHttpRequestよりも[Fetch_API](https://developer.mozilla.org/ja/docs/Web/API/Fetch_API/Using_Fetch)がお勧めです。

1

Try this API

2017/11/26 19:19

投稿

umyu
umyu

スコア5846

test CHANGED
@@ -21,3 +21,7 @@
21
21
 
22
22
 
23
23
  パラメータをよく確認してみてくださいな。
24
+
25
+
26
+
27
+ Try this APIでAPIのテストを試せるのでそれも参考にしてください。