سلام
هنگام ارسال درخواست http با متد post با کد
fetch("http://localhost:3000/send.php", {
method: "POST",
body: JSON.stringify({ data: 'data' })
})
.then(res => {
console.log(`response : ${res.json()}`);
})
.catch(err => {
console.log(`err : ${err}`);
})
با چنین اروری مواجه میشم
Uncaught (in promise) SyntaxError: Unexpected token a in JSON at position 0
و داده ها ارسال نمیشن و آرایه $POST خالیه!!!
مشکل از کجاست؟!؟
@mhyeganeh
@ali.bayat
@hosseinshirinegad98
@khanzadimahdi
const data = {
wallet: walletId,
to: toPhone
}
fetch("http://localhost:3000/send.php", {
method: "POST",
headers: {
"Accept": "application/json,text/plain,*/*",
"Content-Type": "application/json"
},
body: JSON.stringify(data)
})
.then(res => {
console.log(`response : ${res.json()}`);
})
.catch(err => {
console.log(`err : ${err}`);
})
نه کار نکرد 😕
شاید پاسخ شما همینجا باشد