D
D
Div-Man2018-07-25 22:38:09
Laravel
Div-Man, 2018-07-25 22:38:09

How to add an article to the database using the Laravel REST API?

I did everything according to this article https://arjunphp.com/create-rest-laravel-framework/
And how to use routes?

Route::delete('task/{id}','[email protected]');
// update existing task
Route::put('task','[email protected]');
// create new task
Route::post('task','[email protected]');

If you write 127.0.0.1:8000/task in the action , then when submitting the form, there will be an error
Sorry, the page you are looking for could not be found

<form action="http://127.0.0.1:8000/task" method="POST" enctype="multipart/form-data">
                {{csrf_field()}}
                <div class="form-group">
                 <label for="formGroupExampleInput">Описание</label>
                 <input name="description" type="text" class="form-control" id="formGroupExampleInput" placeholder="Введите что-нибудь">
               </div> 
                <button type="submit" class="btn btn-success">Submit</button>
            </form>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem0071, 2018-07-25
@Artem0071

If registered in api.php, then you need to contact 127.0.0.1:8000/api/task

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question