I am new to nodejs i try to use nested callbacks but it gives server crashes most of the time with async nature how can i change my code with async and await with out crashing my server. the error was query undefined.
exports.rpitop = function (req, resp) {
        db.executeSql("SELECT * from Kunden_settings where Benutzer='"+req.body.username+"'", function (data, err) {
            if (err) {
                resp.writeHead(200, { "Content-Type": "text/html" });
                resp.write("<html><head><title>500</title></head></html>");
            }
            else {
                var final_region;
                switch (data[0].product) {
                    case 3:
                        switch (data[0].region) {
                            case 6:final_region  = "nord_h";break;
                            case 7:final_region  = "n_ost_h";break;
                            case 8:final_region  = "ost_h";break;
                        } break;
                    case 4:
                        switch (data[0].region) {
                            case 9:final_region  = "ost_2_d";break;
                            case 10:final_region = "s_ost_d";break;
                            case 11:final_region = "mitte_d";break;
                        } break;
                    case 5:
                        switch (data[0].region) {
                            case 12:final_region = "west_e5";break;
                            case 13:final_region = "r_main_e5";break;
                            case 14:final_region = "s_west_e5";break;
                        } break;
                }
                db.executeSql("SELECT max("+ final_region +") as high, min("+ final_region +") as low from rpi_daten_neu ", function (maxmin, err) {
                    db.executeSql("SELECT * from rpi_daten_neu inner join werte_inc W where datum = (W.bezugsdatum) order by zeit desc limit 1", function (current, err) {
                    if (err) {
                        resp.writeHead(200, { "Content-Type": "text/html" });
                        resp.write("<html><head><title>500</title></head></html>");
                    }
                    else {
                        resp.writeHead(200, { "Content-Type": "x-application/json" });
                        var finalvalue = []
                            for (var i = 0; i < maxmin.length; i++) {
                                for (var i = 0; i < current.length; i++) {
                                    finalvalue.push({
                                        high: maxmin[i].high,
                                        low: maxmin[i].low,
                                        time:momenttime(current[0].zeit, 'HH-mm-ss').format("HH:mm"),
                                        value:current[0][final_region]
                                    })
                                }
                            }
                        resp.write(JSON.stringify(finalvalue));
                    }
                    resp.end();
                });
                });
            }
        });
    }; 
 
    