Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

com.facebook.react.bridge.readablenativemap cannot be cast to java.lang.string

My code:

const file = {
  uri: this.state.imageSource,
  name: this.state.imageName,
  type: 'image/jpg',
};

const data = new FormData();
data.append('file', file);

fetch(config.server + '/upload', {
  method: 'POST',
  body: data,
})
  .then((res) => res.json())
  .then((responseData) => {
    alert(JSON.stringify(responseData));
  })
  .catch((err) => {
    alert(err);
  });

Without FormData code doesnt display error. What I should do to fix? Debugging on android.

like image 909
kutirie Avatar asked May 31 '18 11:05

kutirie


3 Answers

The error was because I was passing in the url as an array but it expected a string.

like image 189
kutirie Avatar answered Nov 20 '22 08:11

kutirie


This will resolve the issue : alert(JSON.stringify(data))

like image 34
Rishav Kumar Avatar answered Nov 20 '22 07:11

Rishav Kumar


I was getting this error because my URL was incorrect

like image 2
Shubham1164 Avatar answered Nov 20 '22 08:11

Shubham1164