From 9e20ac6ec10759ab1e2b25c9752f5e9ae5e9171f Mon Sep 17 00:00:00 2001 From: Zeinab Date: Sat, 9 Dec 2023 10:01:30 +0330 Subject: [PATCH] Refactoring: Add PreScript.http --- Ordering.http | 18 +----------------- PreScript.http | 15 +++++++++++++++ PreferHeader.http | 17 +---------------- Rest.http | 18 +----------------- 4 files changed, 18 insertions(+), 50 deletions(-) create mode 100644 PreScript.http diff --git a/Ordering.http b/Ordering.http index 958ad27..2b496d0 100644 --- a/Ordering.http +++ b/Ordering.http @@ -1,20 +1,4 @@ -{{ - 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; -}} - +# @import ./PreScript.http ### GET /products?order=id.desc diff --git a/PreScript.http b/PreScript.http new file mode 100644 index 0000000..e996b66 --- /dev/null +++ b/PreScript.http @@ -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; +}} \ No newline at end of file diff --git a/PreferHeader.http b/PreferHeader.http index 0a704fe..7171b0d 100644 --- a/PreferHeader.http +++ b/PreferHeader.http @@ -1,19 +1,4 @@ -{{ - 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; -}} + # @import ./PreScript.http ### POST /products diff --git a/Rest.http b/Rest.http index 6f41f40..c7f636a 100644 --- a/Rest.http +++ b/Rest.http @@ -1,19 +1,4 @@ -{{ - 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; -}} +# @import ./PreScript.http ### GET /products/1 @@ -22,7 +7,6 @@ GET /products/1 ?? body id == 1 ### - GET /products ?? status == 200 ?? body length == 77