8

それに基づいてDBを照会できるように、フェッチAPIを介してサーバーにデータを送信したいと考えています。Ajax とは異なり、適切な方法が見つかりません。ここに私のフェッチ呼び出しがあります:

{fetch("http://192.168.90.53:4000/game/?email=adicool2294@gmail.com", {method: "GET"} )
        .then((response) => response.json())
        .then((responseData) => {
            id= responseData.id;
            name= responseData.name; 
            console.log(responseData);
        })
       .catch((error) => {
             console.warn(error);
           }); 
  }
}

サーバーがそれを使用してDBを照会できるように、電子メールなどのパラメーターを送信したい。反応ネイティブのアンドロイドを使用しているため、Ajax リクエストを使用できません。GETメソッドのみを使用したい。現在、URL で渡しているクエリ パラメータは、サーバーによって req.query に表示されません。

4

3 に答える 3

-2
You can add that like below

fetch("http://192.168.90.53:4000/game", obj)  
.then(function(response) => response.json())
.then((responseData) => {
  id = responseData.id;
  name = responseData.name; 
  console.log(responseData);
},
.catch((error) => {
  console.warn(error);
}); 

var obj = {  
  method: 'POST',
  body: JSON.stringify({
    'email': your_email_here,
  })
};
于 2015-12-31T09:11:56.117 に答える