Мой маршрут следующий:
Код: Выделить всё
Route::get('/data', 'CartographieController@dataToJson');
Route::post('/addDraft', 'CartographieController@addDraft');
Код: Выделить всё
public function addDraft(Request $request)
{
$draft = Draft::create($request->all());
return response()->json($draft, 201);
}
Код: Выделить всё
handleAdd(event) {
event.preventDefault();
var draft = {
description: this.state.description,
};
try {
const nextData = clone(this.state);
nextData.drafts.push(draft);
//console.log("state" + this.state);
this.setState({ drafts: nextData.drafts });
console.log("state" + this.state);
} catch (error) {
console.log(error);
}
axios
.post("http://127.0.0.1:8000/addDraft/", this.state.drafts)
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
Запрос не выполнен с кодом состояния 419
Подробнее здесь: https://stackoverflow.com/questions/621 ... xios-react