PUT method Calling api in fetch get Error line in React-native

1.2k Views Asked by At

I have some problem while calling the fetch API using PUT method.

Here is my Code:

var updateString = "{\"first_name\":\""+this.state.updateAccountValues.FirstName+"\",\"last_name\":\""+this.state.updateAccountValues.LastName+"\",\"email\":\""+this.state.updateAccountValues.Email+"\", \"password\":\""+this.state.updateAccountValues.Password+"\", \"billing\": {\"phone\": \""+this.state.updateAccountValues.MobileNumber+"\"}}"
      console.log("string:"+JSON.stringify(updateString))
      fetch('XXXXXXXXXXXXXXXXXXXXX/wp-json/wc/v2/customers/XXXXXX?consumer_key=XXXXXXXXXXXXXXXXXXXXXXXX&consumer_secret=XXXXXXXXXXXXXXXXXXXXXXXXX',{
        method:'PUT',
        headers:{
          'Accept':'application/json',
          'Content-Type':'application/json'
        },
        body:JSON.stringify(updateString)
      }).then((response)=>response.json()).then((responseData)=>{
            alert("Response:"+JSON.stringify(responseData))
            if(responseData.data.status == 404){
                Alert.alert("KOOPI", responseData.message)
              }
         }).catch((err)=>{
                          alert("err:"+JSON.stringify(err))
                        })

I'm getting this error: err: {"line":13982,"column":14,"sourceURL":"http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false"}

Please give your valuable suggestions on my issue, Thanks in advance.

0

There are 0 best solutions below