backend/fastify/all-watchlists/server.js
2024-05-26 19:51:33 +02:00

27 lines
505 B
JavaScript

// Declare a route
module.exports = function (fastify, opts, done) {
const pb = opts.pb;
fastify.post('/all-watchlists', async (request, reply) => {
const data = request.body;
const userId = data?.userId;
let output;
try {
output = await pb.collection("watchlist").getFullList({
filter: `user="${userId}"`
})
}
catch(e) {
//console.log(e)
output = {};
}
reply.send({ items: output })
});
done();
};