Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

React Native to Django Using Axios [Error: Request failed with status code 400]

$
0
0

I have tried almost all options but not getting through. My Django server is working fine with Postman but when I try it from my React Native app, it gives an error

[Error: Request failed with status code 400]

My code is:

submitData = () => {        console.log("submitQuestionDataToServer");        let form_data = new FormData();        form_data.append('qOne_img', Platform.OS === 'android' ? photoUri : photoUri.replace('file://', ''));        form_data.append('qOne_img', Platform.OS === 'android' ? secondPhotoUri : secondPhotoUri.replace('file://', ''));        form_data.append('question_title', qTitle);        form_data.append('asked_by', "http://127.0.0.1:8000/auth/users/2/");        let url = 'http://127.0.0.1:8000/api/questions/';        axios.post(url, form_data, {          headers: {"Content-Type": "multipart/form-data","Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1Nk",        }        })            .then(res => {                console.log("res *******")              console.log(res.data);            })            .catch(err => console.log(err))    }

Thanks in advance.


Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>