I'm trying to send a delete request to my PHP/Codeigniter api. Sending it from a NativeScript-Vue frontend.
async deleteBackedupImages(identifiers) {
console.log(identifiers);
try {
var { data } = await axios({
url: this.apiUrl + "/images?XDEBUG_SESSION_START=dsadsad",
method: "delete",
data:{
identifiers
},
headers: { "X-Requested-With": "XMLHttpRequest","Content-Type": "application/json" }
});
return data;
} catch (error) {
throw error;
}
}
On the PHP side of things, i have this function to take care of the JSON data:
function getJSONData():stdClass{
try {
$ci =& get_instance();
$stream_clean = $ci->security->xss_clean($ci->input->raw_input_stream);
$request = json_decode($stream_clean);
return $request;
} catch (\Throwable $th) {
throw $th;
}
}
"identifiers" is just an array of strings.
$stream_clean variable comes out as an empty string, instead of JSON string.
I have to say it's a bit weird, that Axios docs state the following:
//
data
is the data to be sent as the request body // Only applicable for request methods 'PUT', 'POST', and 'PATCH'
I've seen on various posts, that a data object can actually be sent with a delete request.
What could be the problem with my code?