I have a problem with checking some URLs and their status code. I have a php function
public function checkUrl(Request $request)
{
$curl = curl_init($request->url);
curl_setopt($curl, CURLOPT_NOBODY, true);
curl_exec($curl);
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
return $code;
}
And in Vue I call it like this
Object.keys(this.items).forEach(key => {
let value = this.items[key];
let checkUrl = value.url + this.usersearch;
fetch('/api/checkurl', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
mode:'cors',
cache:'default',
body: JSON.stringify({url:checkUrl}),
})
When I check them I get the Uncaught TypeError: Failed to construct 'Request': Request with GET/HEAD method cannot have body. With method POST works fine, but I need to get the URLs checked with GET method. If anyone has idea what am I doing wrong here, I would be very grateful.