Is there a way to throw an error if property could not be found from data.
Problem is, it is mapping undefined instead of throwing error.
const insertIntoTable = function(data) {
return new Promise((resolve, reject) => {
const entry = {
Id: data.id,
Method: data.Method,
Status: data.PaymentStatus,
InsertedAt: (new Date().getTime())
}
}).catch((error) => {
console.log(error);
});
}
You can check if the properties are undefined by comparing it to undefined. For example, if you wanted to check the id property, you could use
if(data.id === undefined){
throw new Error();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With