简体   繁体   中英

Post data with api React-native

this api niceyl work in postman but I try this code in react-native it is not working how to fix it?

const a ={
    ad:'test',
    telefon:'test',
    islem:'test',
    sube:'test',
    saat:'test',
};
async function harrik(){
   await fetch('https://localhost/api/test/cetran', {
    method: 'POST',
    headers: {
        'Accept':'application/json',
        'Content-Type': 'application/json',
    },
    body:a,
    }).then((response)=>{
        console.log(JSON.stringify(response));
    }).catch((e)=>{
        console.log(e);
    });
}

I solved like this:

body:JSON.stringify(a),

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM