tanhakabir / rest-book

REST Book is a Visual Studio Code extension that allows you to perform REST calls in a Notebook interface.
https://marketplace.visualstudio.com/items?itemName=tanhakabir.rest-book
MIT License
249 stars 24 forks source link

More variables #103

Closed danieljharris closed 3 years ago

danieljharris commented 3 years ago

It would be amazing if we could manually set variables in addition to assigning them from request responses.

Set variables something like this:

let url = "https://www.myapi.com";

let port = 3000;

let default_header = User-Agent: rest-book;

let name = "Foo";

And use them in later cells (maybe with better syntax):

POST ($url)($port)/api
$default_header
Content-Type: application/json

{
    name: $name,
    text: "Foo is the most bar of the Foos" 
}

And be able to reuse them throughout:

GET ($url)($port)/users
$default_header
nat1craft commented 3 years ago

I second this! More cowbell Variables! Highly useful.

tanhakabir commented 3 years ago

sure! can do

tanhakabir commented 3 years ago

Add ability to use constants like this in release 2.0.2:

image image

I'll publish 2.0.2 on the marketplace once I get better reception

tanhakabir commented 3 years ago

Pushed a new release with this for 2.1.0

nat1craft commented 3 years ago

I noticed that using the variable as the endpoint for a POST (for example) did not seem to work. If I however copy/pasted the value in place of the variable, it works fine. (v 2.1.0)

image

tanhakabir commented 3 years ago

@nat1craft fixed in 2.2.0!

nat1craft commented 3 years ago

Confirmed; That is a really nice feature. Thanks again for your hard work!