Huachao / vscode-restclient

REST Client Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=humao.rest-client
MIT License
5.29k stars 439 forks source link

Executing a request within an .http (or .rest) file from NodeJS #750

Open dremekie opened 3 years ago

dremekie commented 3 years ago

Hi. Great plugin. We use it a lot.

From within Node, we would love to be able to do something like this:

# my-requests.http

@url = https://api.dummy.com

###

# @name getUser
GET {{url}}/users/{{userId}}
Content-Type: application/json
Authorization: Bearer {{apiKey}}
const httpFile = 'my-requests.http';
const vars = { apiKey: '1234', userId: '456' };
const requestName = 'getUser';
const response = await restClient.execute(httpFile, vars, requestName);

I'm sure this must be possible in some manner using the logic you are already using in the plugin?

dremekie commented 3 years ago

Just a note. My request would make #759 easy to implement (not necessarily by you... by the community).

cplussharp commented 3 years ago

I think to support this and other vscode-independent usages, the project would need to be split up into three packages: a parser, a cli runner and the vscode-plugin

dremekie commented 3 years ago

I saw a comment from #432 that mentioned https://github.com/AnWeber/httpyac/.

It has all the features many have been asking for (in addition to the features of vscode-restclient). CLI runner and a library allowing programmatic execution of any or all http regions. Very nice.

I'll leave this ticket open (in case the author does plan on adding the requested features).