-1

backend is expecting something like

 { "key" : "xyz" }// and two files 

I've tried the following code, but it always shows empty params passed in url

 const obj = { key : [this.state.key] }; const json = JSON.stringify(obj); const blob = new Blob([json], { type: 'application/json' }); const data = new FormData(); data.append("params", blob); data.append("data1",this.state.file1) data.append("data2",this.state.file2) let res= await axios.get(url,data); console.log(res) 
2

2 Answers 2

0

You can't send data(body) by using get method. I think you need to use post method.

 const obj = { key : [this.state.key] }; const json = JSON.stringify(obj); const blob = new Blob([json], { type: 'application/json' }); const data = new FormData(); data.append("params", blob); data.append("data1",this.state.file1) data.append("data2",this.state.file2) let res= await axios.post(url,data);

Sign up to request clarification or add additional context in comments.

Comments

0

You cannot use formData with get, in order to send with body, file upload has to be a post request.

let res= await axios.post(url,data); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.