I can’t get rid of this error no matter what I try… can anyone help me please?
ERROR (node:9) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
Here’s my code:
exports.handler = (event, context, callback) => {
main(event)
.then(response => {
console.log(response);
callback(null, response);
})
.catch(error => {
console.log(error);
});
};
async function main(event, callback) {
try {
const client = new faunadb.Client({
secret: process.env.SECRET
});
const reservation = JSON.parse(event.body);
let reservationBlockRef = null;
if (reservation.reservationBlock) {
reservationBlockRef =
reservation.reservationBlock.reservationBlock.ref['@ref'].id;
}
// double check here to see if a reservation block exists
if (!reservationBlockRef) {
const { data } = await client.query(
//query
);
for (let block of data) {
if (
block.data.start_time === reservation.start &&
block.data.end_time === reservation.end
) {
reservationBlockRef = block.ref.id;
}
}
}
// if it really doesn't exist at this point, we're creating one
if (!reservationBlockRef) {
// first create the block then create the reservation and add it to the block
const response = await client.query(
//query
);
return new Promise(resolve => {
resolve({
headers: {
'Access-Control-Allow-Origin': '*'
},
statusCode: 200,
body: JSON.stringify(response)
});
});
}
// if the request was sent with a block, or we found a block previously
const res = client.query(
// query
);
return new Promise(resolve => {
resolve({
headers: {
'Access-Control-Allow-Origin': '*'
},
statusCode: 200,
body: JSON.stringify(res)
});
});
} catch (error) {
return new Promise(resolve => {
resolve({
headers: {
'Access-Control-Allow-Origin': '*'
},
statusCode: 200,
body: JSON.stringify(error)
});
});
}
}