Refactoring: Add PreScript.http
This commit is contained in:
@@ -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
15
PreScript.http
Normal 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;
|
||||||
|
}}
|
||||||
@@ -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
|
||||||
|
|||||||
18
Rest.http
18
Rest.http
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user