bruno/packages/bruno-tests/collection/scripting/inbuilt modules/axios/axios-pre-req-script.bru
Anoop M D 753a576c3c
Feat/safe mode quickjs (#2848)
Safe Mode Sandbox using QuickJS
Co-authored-by: Anoop M D <anoop.md1421@gmail.com>
Co-authored-by: lohit <lohit.jiddimani@gmail.com>
2024-08-21 12:52:49 +05:30

35 lines
539 B
Plaintext

meta {
name: axios-pre-req-script
type: http
seq: 1
}
get {
url: {{host}}/ping
body: none
auth: none
}
script:pre-request {
const axios = require("axios");
const url = "https://testbench-sanity.usebruno.com/api/echo/json";
const response = await axios.post(url, {
"hello": "bruno"
});
req.setBody(response.data);
req.setMethod("POST");
req.setUrl(url);
}
tests {
test("req.getBody()", function() {
const data = res.getBody();
expect(data).to.eql({
"hello": "bruno"
});
});
}