Many of us use Postman to test our Rest APIs, switching between vscode and postman. But what if there is a way to do it using vscode only. That's where Rest Client vscode extension comes in. So, in this post the way to use this extension is described below.
Step 1: Installing REST Client Extension
- Opening VS Code.
- Extensions tab (Ctrl + Shift + X).
- Searching for REST Client (by Huachao Mao).
- Installing the extension
Step 2: Creating a .http or .rest File
In our Laravel project, new file with the extension .http or .rest needs to be created.
Example: api-test.http
Step 3: Writing API Requests
We can now write and test API requests directly from VS Code editor.
One important thing to note here is that multiple requests can be written sequentially in the same file as examples. However, when making a request, ensure that only one request is active while keeping the others commented out.
This prevents conflicts and ensures the correct request is executed.
POST http://localhost:8000/api/user-register Content-Type: application/json { "name" : "Demo User", "email" : "du@demo.com", "mobile" : "013222915310", "password" : "12345678" } POST http://localhost:8000/api/user-login Content-Type: application/json { "email" : "du@demo.com", "password" : "12345678" } GET http://localhost:8000/api/user-profile token: our-token Accept: application/json POST http://localhost:8000/api/create-category token: our-token Content-Type: application/json { "name" : "monitor" } POST http://localhost:8000/api/update-category token: our-token Content-Type: application/json { "id" : "28", "name" : "monitor 2025" } POST http://localhost:8000/api/delete-category token: our-token Content-Type: application/json { "id" : "28" } POST http://localhost:8000/api/category-by-id token: our-token Content-Type: application/json { "id" : "28" } GET http://localhost:8000/api/user-logout
Step 4: Running Laravel server
Before sending api requests we need to make sure laravel server is running
php artisan serve
Step 5: Sending requests
There will be "Send Request" link just above the request url the one we are testing. We need to click that.
The response will appear in a new tab in VS Code.
That's it. Now we dont need to go outside of vscode to test our laravel api requests.