How to make REST calls from inside VS Code?

I am a developer from Delhi, India
Search for a command to run...

I am a developer from Delhi, India
Hey Guys! Here's how to make a REST call from inside Visual Studio Code. I hope you find it helpful and increase your productivity and efficiency
DISCLAIMER: This might not be the most well-written article since I haven't written in a while and I just wanted to get back to writing with a short article about my experience of the day, so sorry about that I previously used this repository for my...

The release of NextJS 13 brought about a plethora of new and impressive features, with one standout being the updated data fetching and management process. The fetch API replaced the more complicated functions, including getServerSideProps, getStatic...

Looking for a safe and reliable way to authenticate users? Consider implementing magic links. They offer a secure alternative to traditional passwords and can help mitigate the risk of password leaks and forgotten passwords. Magic Link authentication...

Neovim is a powerful text editor that can be customized with plugins to enhance its functionality. In this article, we will explore the top 10 essential Neovim plugins. These plugins can help improve your Neovim experience by adding features such as ...

A type-safe and zero-runtime version of Tailwind CSS

In one of my previous blogs, I have talked about Postman and how useful it can be for both frontend and backend development. Click on the below link to check it out!
But, if you're like me, a person who likes to do major of his work in one software, then you'd also want to make REST calls inside of VS Code (my favourite editor, as of now). So, a man, named Huachao Mao, made an extension called REST Client to overcome this problem, and believe me, it's been very useful for me, till now.
You can install the extension from inside VS Code by typing Rest Client inside the extensions search bar.
The above features have been taken from the official documentation of *REST Client. You can visit it from the link below for more information. https://marketplace.visualstudio.com/items?itemName=humao.rest-client
Let's start by making a GET Request.

GET https://jsonplaceholder.typicode.com/posts

I have used the JSONPlaceholder.typicode.com fake rest api for demonstration purposes. You can use any url which supports get.

Pretty easy, right? ๐
###

Now, for a POST request, start like before and add the below line
POST https://jsonplaceholder.typicode.com/posts
In a POST request, we usually send a request body and if you've used fetch
api or some other way of fetching a post request, you would know, that we need to set the content to application/json to send a request body as json.
To do that we add the line given below just below the request URL.
Content-Type: application/json
Adding a request body Leave a line after the Content-Type line and add the request body like so
{
"userId" : 1,
"title": "Hello World from REST Client VSCode",
"body": "This is how to make a REST Call from inside VSCode"
}

And that's it... We've come to an end to the basics of the REST Client extension inside VSCode. As time goes on, you can read the documentation for your use case like adding authentication tokens, adding headers, etc.
That's it for today, and I hope you found something useful from this. You can find the code used above in the following gist