How does the back end receive the data sent in fetch mode?

The

fetch method simulates the request of the form with the help of the FormData object

this enables a complete HTTP request, and the back end can also receive data like a form

//
var formdata = new FormData();
formdata.append("username","lofayo");
fetch("web.php",{
    method: "POST",
    body:formdata
})
.then(res=>res.text())
.then(resTxt=>console.log(resTxt))

//
//web.php
$username = $_POST["username"]

post request in fetch mode, data or mock form. but , if you submit data directly like fetch official website , how can the backend receive it?

is not like a form, but a string, so how should the daemon receive it?

var url = "https://example.com/profile";
var data = {username: "example"};

fetch(url, {
  method: "POST", // or "PUT"
  body: JSON.stringify(data), // data can be `string` or {object}!
  headers: new Headers({
    "Content-Type": "application/json"
  })
}).then(res => res.json())
.catch(error => console.error("Error:", error))
.then(response => console.log("Success:", response));
Mar.11,2021

  

the backend prints $_ POST, and you can see the data format

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e45e9e-438aa.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e45e9e-438aa.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?