60 lines
1.2 KiB
HTTP
60 lines
1.2 KiB
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
|
|
Content-Type: application/json
|
|
Prefer: return=representation
|
|
|
|
{
|
|
"id": 78,
|
|
"product_name": "Saffaron",
|
|
"discontinued": 0,
|
|
"supplier_id": 12,
|
|
"category_id": 2,
|
|
"quantity_per_unit": "20 mg",
|
|
"unit_price": 100,
|
|
"units_in_stock": 50,
|
|
"units_on_order": 0,
|
|
"reorder_level": 10
|
|
}
|
|
?? status == 201
|
|
?? js response.parsedBody.length == 1
|
|
?? js response.parsedBody[0].id == 78
|
|
?? js response.parsedBody[0].product_name == Saffaron
|
|
|
|
###
|
|
|
|
POST /products
|
|
Content-Type: application/json
|
|
Prefer: return=headers-only
|
|
|
|
{
|
|
"id": 78,
|
|
"product_name": "Saffaron",
|
|
"discontinued": 0,
|
|
"supplier_id": 12,
|
|
"category_id": 2,
|
|
"quantity_per_unit": "20 mg",
|
|
"unit_price": 100,
|
|
"units_in_stock": 50,
|
|
"units_on_order": 0,
|
|
"reorder_level": 10
|
|
}
|
|
?? status == 201
|
|
?? header location == /products?id=eq.78
|