curlコマンドをfetchAPIに変換したい
curlコマンドでは取得できているのですが、
fetchAPIを用いて通信を行おうとすると、データが取得できてないです。
Jqueryのajaxでは成功しています。
fetchAPI
https://github.com/github/fetch
curlコマンド
cmd
1 $curl -X POST "url" -d name="test"
Ajaxでは成功する
Jquery
1 $.ajax({ 2 crossDomain: true, 3 url: 'url', 4 type: 'POST', 5 data: { 6 "name": "test" 7 }, 8 timeout: 10000, 9 success: function(xml, textStatus, xhr) { 10 console.log(); 11 }else{ 12 } 13 }, 14 error: function(xhr, textStatus, error) { 15 } 16 });
fetchAPIで失敗する
fetch('url', { method: 'POST', mode: 'cors', credentials: 'inClude', data: {"name": "getFollowees"} }).then(function(response) { console.log(response); }).then(function(json) { console.log(json); });
dataがうまく飛ばせてない感じがします・・・
どうかご回答願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/04/20 06:26