I keep getting this CSRF token mismatch via an api call. Is there a way to handle it in a graceful way? I heard that disabling it is not advisable. I am using this library plus this code
public function add()
{
$location = $this->Locations->newEntity();
if ($this->request->is('post')) {
$location->code = $this->request->getData('code');
$location->name = $this->request->getData('name');
if ($this->Locations->save($location)) {
$this->set([
'success' => true,
'_serialize' => ['success']
]);
}
}
}
I keep getting this CSRF token mismatch via an api call. Is there a way to handle it in a graceful way? I heard that disabling it is not advisable. I am using this library plus this code