How can I pass POST parameters in fetch request? - React Native

前端 未结 2 1253
长情又很酷
长情又很酷 2021-02-07 19:29

This is my code:

componentWillMount() {
  fetch(\"http://10.4.5.114/localservice/webservice/rest/server.php\", {
    method: \'POST\',
    body: JSON.stringify({         


        
2条回答
  •  名媛妹妹
    2021-02-07 20:08

    Try to add header in post request.

           headers: {
             'Accept': 'application/json',
             'Content-Type': 'application/json',
    
           },
           body: JSON.stringify({
             wstoken: 'any_token',
             wsfunction: 'any_function',
             moodlewsrestformat: 'json',
             username: 'user',
             password: 'pass',
          })
    

提交回复
热议问题