JSFiddle - React, Tailwind, and code Playground

by Jerga99

JavaScript

//IMAGINE THIS AS MONGODB FUNCTION
// we dont have access to this function
function find(query, callback) {  
    if (query) {
      const rentals = [1,2,3];
      callback(undefined, rentals);
    } else {
      callback({err: 'ERROR!'}, undefined);
    }
}


/* LET"S FIND RENTALS */
/* THIS IS OUR CODE */
find('some query', function(err, foundRentals) {
 if (err) {
   alert(err);
 }
 
 alert(foundRentals);
})