Answer the question
In order to leave comments, you need to log in
How to stop the script if the data from Mongoose came empty?
Good day!
Let me get straight to the question:
This script in the photo receives transactions from the database, and if they exist, it returns an error.
However, the work of the entire script does not stop. How can I make sure that the script below this interaction does not work?
I don't need to do any further work if there is an error. In my case, it will return an error and continue to execute the script. (headers error appears)
Answer the question
In order to leave comments, you need to log in
Решил проблему следующим методом:
(async () => {
const transaction = await GameController.isTransactionCompleted(req.body.transaction_id);
if (transaction.length !== 0) return bla-bla-bla
});
async isTransactionCreated(transaction_id) => {
let total_transactions;
await GameModel.find({ transaction_id: transaction_id }, (error, transaction) => {Ваши извращения из Pomise можно записать в total_transactions и вернуть его же});
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question