pactest/consumer/orderClient.js
Sander Hautvast 9e8b0de006
Some checks failed
test / Test completion check (push) Has been cancelled
test / test (20, macos-latest) (push) Has been cancelled
test / test (20, ubuntu-latest) (push) Has been cancelled
test / test (20, windows-latest) (push) Has been cancelled
test / test (22, macos-latest) (push) Has been cancelled
test / test (22, ubuntu-latest) (push) Has been cancelled
test / test (22, windows-latest) (push) Has been cancelled
test / test (24, macos-latest) (push) Has been cancelled
test / test (24, ubuntu-latest) (push) Has been cancelled
test / test (24, windows-latest) (push) Has been cancelled
Initial commit
2025-09-03 11:48:59 +02:00

23 lines
508 B
JavaScript

const request = require("superagent");
const { Order } = require("./order");
const hostname = "127.0.0.1"
const fetchOrders = () => {
return request.get(`http://${hostname}:${process.env.API_PORT}/orders`).then(
(res) => {
return res.body.reduce((acc, o) => {
acc.push(new Order(o.id, o.items));
return acc;
}, []);
},
(err) => {
console.log(err)
throw new Error(`Error from response: ${err.body}`);
}
);
};
module.exports = {
fetchOrders,
};