Refactoring: Add PreScript.http

This commit is contained in:
2023-12-09 10:01:30 +03:30
parent 3cd00d74bf
commit 9e20ac6ec1
4 changed files with 18 additions and 50 deletions

View File

@@ -1,20 +1,4 @@
{{ # @import ./PreScript.http
const axios = require('axios');
const wait = axios.get(`${host}/products`).then(res => {
let length = res.data.length;
let exists = res.data.find(item => item.id === 78);
if(length===78 && exists){
return axios.delete(`${host}/products?id=eq.78`)
.then(res => {
return null;
})
}
return null;
})
exports.wait = wait;
}}
### ###
GET /products?order=id.desc GET /products?order=id.desc

15
PreScript.http Normal file
View File

@@ -0,0 +1,15 @@
{{
const axios = require('axios');
const wait = axios.get(`${host}/products`).then(res => {
let length = res.data.length;
let exists = res.data.find(item => item.id === 78);
if(length===78 && exists){
return axios.delete(`${host}/products?id=eq.78`)
.then(res => {
return null;
})
}
return null;
})
exports.wait = wait;
}}

View File

@@ -1,19 +1,4 @@
{{ # @import ./PreScript.http
const axios = require('axios');
const wait = axios.get(`${host}/products`).then(res => {
let length = res.data.length;
let exists = res.data.find(item => item.id === 78);
if(length===78 && exists){
return axios.delete(`${host}/products?id=eq.78`)
.then(res => {
return null;
})
}
return null;
})
exports.wait = wait;
}}
### ###
POST /products POST /products

View File

@@ -1,19 +1,4 @@
{{ # @import ./PreScript.http
const axios = require('axios');
const wait = axios.get(`${host}/products`).then(res => {
let length = res.data.length;
let exists = res.data.find(item => item.id === 78);
if(length===78 && exists){
return axios.delete(`${host}/products?id=eq.78`)
.then(res => {
return null;
})
}
return null;
})
exports.wait = wait;
}}
### ###
GET /products/1 GET /products/1
@@ -22,7 +7,6 @@ GET /products/1
?? body id == 1 ?? body id == 1
### ###
GET /products GET /products
?? status == 200 ?? status == 200
?? body length == 77 ?? body length == 77