React Native - Fetch POST request is sending as GET request

后端 未结 11 1123
感情败类
感情败类 2020-12-16 14:52

I\'m having issues when using FETCH.

I am trying to make a POST request using FETCH in react-native.

    fetch(\"http://www.example.co.uk/login\", {
         


        
11条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-16 15:41

    If you wanna do POST request using fetch, You can do like that

            fetch('url?email=a@gmail.com&password=a@gmail.com', {
                 method: 'POST'
              })
              .then((response) => response.json())
              .then((responseJson) => {
                 console.log(responseJson);
                 // this.setState({
                 //    data: responseJson
                 // })
              })
              .catch((error) => {
                 console.error(error);
              });
    

提交回复
热议问题