mirror of
https://github.com/usebruno/bruno.git
synced 2025-01-05 21:48:56 +01:00
35 lines
539 B
Plaintext
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"
|
||
|
});
|
||
|
});
|
||
|
|
||
|
}
|