Search code examples
reactjsreact-nativereact-native-fetch-blob

How to delete file from API using React-Native-Fetch-Blob?


I'm trying to remove the file from the API using React-Native-Fetch-Blob, but it doesn't work. However when trying to delete the file using Postman it works.

var dataToServer = { 'path' : this.state.path};

RNFetchBlob.fetch('DELETE', 'url', {
        'Authorization' : tokenJSON.access,
        'Content-Type' : 'application/json',
      }, JSON.stringify(dataToServer))
      .uploadProgress((written, total) => {
        console.log('uploaded', written / total)
      })

Solution

  • Try with "regular" fetch from Fetch API

    fetch(url, {
        method: 'DELETE',
        headers: {
            'Authorization': tokenJSON.access,
            'Content-Type': 'application/json',
        },
    }).then(response =>
    
    );