Open kominetz opened 3 years ago
Thanks for submitting an issue! Will work on this, this upcoming week!
Hey @kominetz, I've added a "half-baked" experience of what you've asked for in the latest. You can declare variables corresponding to the call you want to make and then reference those variables later when sending the body of a call.
Like so:
I currently don't have it so that you can use the value from a previous call with an object; it has to be on its own for now. Also I was curious if you wanted to also use data from the response of a previous call in the headers or parameters?
Nice! Headers, maybe. Parameters, absolutely! BTW, the video loop to demonstrate is a great idea. I think we're closing in on cookie dough more than half-baked if there can be some kind of string interpolation for the parameters.
Here's an updated video of how it works now!
I also support variables in headers, parameters, and as standalone bodies.
I don't have something like this yet
{
"foo": "bar",
"data": $previousCall.data
}
You mention you support parameters, yet is there some trick to it? I tried without luck. This would be extremely nice to have imho.
assuming previous call of:
let employees_reponse = GET .... then the next call to use one of its values... GET https://myserver.com/api/v2/companies/123/employees/$employees_response.data.0.employeeId
Currently does not work for me as it come across literally (and not the value referenced).
@nat1craft Currently I only had it for parameter values not routing paths. I can add this today!
@nat1craft should work in latest 1.9.1 version!
"Add variable resolving to url paths. The only place where variables don't work currently is variables embedded within objects in bodies; stand alone variable references in bodies do work."
Hrm... maybe I am missing something... v1.9.1... still coming across literally for me. In the screenshot below, the url should be .../employee/813669327 but it comes over as .../employee/$employees_reponse.data.0.employeeId
Note: I reloaded VSCode Insiders just in case... and the new version ... I think kills the plugin. Seems like I can no longer invoke the web calls anymore (using either the play buttons or ctrl+alt+enter). I have two different machines here and both exhibited the same behavior after reloading VS Code Insiders to new version.
@nat1craft you're right there was an breaking vscode API change last night, just pushed a fix in version 1.9.2. Should be available to update in the next 10 minutes!
Could you please check then and let me if you're still having issues with variables?
Just happened to see the update 1.9.2. Updated to it and can now run it again (yay!). However, I still see the same problem as shown in the screenshot above. I see it posting to the URL with the actual variable in it (not the value of the variable). I even made sure I spelled the variable right using intellisense as a guide. (Btw: that really is a nice touch)
@nat1craft hmm I'm noticing you're accessing data through data.0
, if data is an array you should be accessing it through data[0]
instead since there is no value in your object with the key "0". That should fix your query.
I did notice however I'm missing some intellisense for objects in arrays (will fix that now)
@nat1craft pushed an intellisense fix in 1.10.0!
Works! Note: I was wondering about the array syntax. If you hit "." after the array name (like data. ) Intellisense still leads you to the number without brackets (like data.1 ) however 1) I can live with that and 2) I probably shouldn't be typing the dot anyway. If you type the bracketed number then type the dot (like data[1]. ) , Intellisense correctly picks back up.
I appreciate the work. Really great plugin!
Hi there, thanks for great work!
{
"foo": "bar",
"data": $previousCall.data
}
Is this supposed to be working now? Do I MUST use VSCode Insiders? I am using VSCode version 1.65.0
There are lots of reasons why I might want something like this, but the specific use case that came to mind during your excellent demo today would be for ad hoc testing of REST APIs where I need data from a response (e.g., a list of IDs) in a subsequent request (e.g., return XMPP presence for just those users selected based on a query).
I use a few tools to do things like this now, but I'm generally pawing through a response and picking out the pieces I want to paste into requests. It would be like a light version of BDD testing where markdown cells can contain information for developers, consumers, business analysts, etc.