React Native - Fetch POST request is sending as GET request

后端 未结 11 1151
感情败类
感情败类 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:38

    This worked for me:

    let data = {
      method: 'POST',
      credentials: 'same-origin',
      mode: 'same-origin',
      body: JSON.stringify({
        appoid: appo_id
      }),
      headers: {
        'Accept':       'application/json',
        'Content-Type': 'application/json',
        'X-CSRFToken':  cookie.load('csrftoken')
      }
    }
    return fetch('/appointments/get_appos', data)
            .then(response => response.json())  // promise
            .then(json => dispatch(receiveAppos(json)))
    } 
    

提交回复
热议问题