Thunder Client is a lightweight Rest API Client Extension for VS Code.
loading of Node Modules
from scripts #1434, #1442, #1429, #1405mongodb
, oracledb
, node-postgres
, @azure/identity
etc..v1.13.0
Load Module syntax
const oracledb = await tc.loadModule("oracledb");
console.log(oracledb);
split
collection into multiple request files to reduce merge conflictsunsaved
indicator #1493setting the body
in the Pre-Request script.JSON File Indent Size
vscode setting addedv1.12.13
// set JSON body
tc.request.setBody({
color:"red"
})
// set XML body
tc.request.setBody("<xml> xml_content </xml>");
// set Text body
tc.request.setBody("plain text body here");
// set Multi-part form
tc.request.setBody({
form: [{
name: "test",
value: "123"
}],
files: [{
name: "file1",
value:"file_path_relative_or_absolute"
}]
}, "formdata")
// set form-urlencoded
tc.request.setBody({
form: [{
name: "test",
value: "123"
}]
}, "formencoded")
// set GraphQL body
tc.request.setBody({
query: `query {
countries {
name
}
}`,
variables: {
"data": {
"hero": {
"name": "R2-D2"
}
}
}
}, "graphql")
// set Binary File body
tc.request.setBody("file_path/test.csv", "binary")
Server Sent Events (SSE)
support #705, #319Web Socket
support #3, #336, #857--reqlist
cmd #1489v1.12.1
Autocomplete
Environment variables #151, #1194Skip Folder
Option in Run Collection #1476Skip Collection
option in CLI for Run ALL CollectionsActive Environment
selection changes to local memory
#1250, #448field Content Type
in a Multi-Part Form Request #1482v1.12.0
{{
.Skip Folder
option to skip multiple requests in the Run Collection view.tc --col all --skip "ColA,ColB"
Active Environment
selection changes to local memory
using the setting. This helps to avoid creating unnecessary Source Control activity.
content-type
to the field names
Request URL
field.
await tc.retryRequest()
function added to tc
APIDNS Test
command added to Command Palette.v1.11.6
await tc.retryRequest()
function added suitable for retrying same request when failedPost Request script
let incrementCount = parseInt(tc.getVar('incrementCount') || "0");
let code = tc.response.status;
if(incrementCount <= 3 && code !== 200)
{
incrementCount = incrementCount + 1
tc.setVar('incrementCount', incrementCount)
console.log("retrying request", incrementCount);
await tc.delay(incrementCount * 1000); // exponential delay of 1 secs
await tc.retryRequest();
}
else
{
tc.setVar('incrementCount', 0);
console.log("reset incrementCount = 0");
}
DNS Test
command for localhost connection issuesResponses Visualisation
(Beta) #511default values for Request Headers
#845tc.chartHTML()
from the Tests tab scriptingtc.chartHTML(templace, data)
, the data is available in chart_data
global variablevar template = `
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.7.8/handlebars.min.js"></script>
<div id="output"></div>
<script id="entry-template" type="text/x-handlebars-template">
<div class="entry">
<h2>{{first_name}}</h2>
<div class="body">
{{email}}
</div>
</div>
</script>
<script>
var source = document.getElementById("entry-template").innerHTML;
var template = Handlebars.compile(source);
document.getElementById("output").innerHTML = template(chart_data[0]);
</script>
`;
var data = tc.response.json.data;
tc.chartHTML(template, data);
thunder-client.defaultHeaders
v1.10.0
Copy Path
or Copy Relative Path
accordingly// test-import.js file
function helloWorld(){
return "hello world";
}
module.exports = {
helloWorld
}
require
var {helloWorld} = require("thunder-tests/test-import.js");
var result = helloWorld();
console.log(result);
Environment variable
, so you don't have to change the path in every request if you move the file to different folder.var scriptPath = tc.getVar("scriptPath");
var {helloWorld} = require(scriptPath);
var result = helloWorld();
console.log(result);
tc.skipRequest("requestId");