简体   繁体   中英

Tesing Laravel API Routes using POSTMAN

I am very sorry if my question sounds foolish. I am new to Laravel. I develop some API in Laravel to be used in Angular, but a bit confused about what to type in POSTMAN in order to test the APIs. The project name is ' ntiapi '

I have written the API in the Controller. Also, I have done the api.php in routes

api.php


Route::post('/register', 'AuthController@register');

Route::post('/login', 'AuthController@login');

Route::post('/logout', 'AuthController@logout');

Route::get('/tasks', 'TaskController@index')->name('tasks.index');

Route::post('/tasks', 'TaskController@store')->name('tasks.store');

Route::get('/tasks/{task}', 'TaskController@show')->name('tasks.show');

Route::put('/tasks/{task}', 'TaskController@update')->name('tasks.update');

Route::delete('/tasks/{task}', 'TaskController@destroy')->name('tasks.destroy');

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

I have this http://localhost:ntiapi/api/

How do I add each of the routes to http://localhost:ntiapi/api/ in order to test the api on the POSTMAN. I mean the complete url. For example http://localhost:ntiapi/api/login .

If there is no route prefix or group prefix it should be

http://localhost/ntiapi/public/api/login

and if you are running artisan server ( php artisan serve )

it should be http://127.0.0.1:8000/api/login or http://localhost:8000/api/login whatever you prefer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM