Экспресс-данные JS JSON из метода get не обрабатываются - PullRequest
0 голосов
/ 30 октября 2019

У меня есть метод get, который извлекает данные из хранимой процедуры, после чего я хочу отправить электронное письмо клиенту. Для редактирования этих данных JSON я использовал несколько методов для их анализа, например, получение данных в виде индексов массива, но вывод «НЕ УКАЗАН».

Вот мой код:

app.get('/userinfo',(req,res)=>{  
    dbconn.query('exec sp_GetDueList',(err,rows,fields)=>{
        if(!err){
            let subject = 'daily guage list';
            res.send(rows.recordsets);
            let hello = JSON.stringify(rows.recordsets);
            let body = hello;
            email.mainemail(subject, body, res).catch((err) => {
                                console.log(err);
            })
        } else{
            res.send(err);
        }
        res.end();
    })
})

Вотвывод по электронной почте:


[[{"Instrument":"Coating Thickness Gauge","ID_No":"BG-05","NextDueDate":"2019-10-17T00:00:00.000Z"},{"Instrument":"Coating Thickness Gauge","ID_No":"BG-06","NextDueDate":"2019-10-17T00:00:00.000Z"},{"Instrument":"Coating Thickness Gauge","ID_No":"BG-07","NextDueDate":"2019-10-17T00:00:00.000Z"},{"Instrument":"Coating Thickness Gauge","ID_No":"BG-09","NextDueDate":"2019-09-15T00:00:00.000Z"},{"Instrument":"Coating Thickness Gauge","ID_No":"BG-10","NextDueDate":"2019-09-15T00:00:00.000Z"},{"Instrument":"Coating Thickness Standards","ID_No":"TS-04","NextDueDate":"2019-09-01T00:00:00.000Z"},{"Instrument":"Deep Freezer","ID_No":"LE-05","NextDueDate":"2019-11-07T00:00:00.000Z"},{"Instrument":"DSC Tester ","ID_No":"LE-04","NextDueDate":"2019-09-17T00:00:00.000Z"},{"Instrument":"Freezer ","ID_No":"LE-11","NextDueDate":"2019-11-07T00:00:00.000Z"},{"Instrument":"Holiday Detector ","ID_No":"HD-349","NextDueDate":"2019-11-20T00:00:00.000Z"},{"Instrument":"Holiday Detector ","ID_No":"HD-488","NextDueDate":"2019-10-15T00:00:00.000Z"},{"Instrument":"Jeep Meter ","ID_No":"JM-02","NextDueDate":"2019-09-26T00:00:00.000Z"},{"Instrument":"Lab Oven ","ID_No":"LE-09","NextDueDate":"2019-11-07T00:00:00.000Z"},{"Instrument":"Lab Oven (CDT) ","ID_No":"LE-06","NextDueDate":"2019-11-07T00:00:00.000Z"},{"Instrument":"Microscope","ID_No":"LE-01","NextDueDate":"2019-11-07T00:00:00.000Z"},{"Instrument":"Pit Gauge","ID_No":"PG-10","NextDueDate":"2019-09-25T00:00:00.000Z"},{"Instrument":"Pit Gauge","ID_No":"PG-11","NextDueDate":"2019-09-27T00:00:00.000Z"},{"Instrument":"Pit Gauge","ID_No":"PG-12","NextDueDate":"2019-08-18T00:00:00.000Z"},{"Instrument":"Salt Contamination Meter","ID_No":"TM-01","NextDueDate":"2019-08-24T00:00:00.000Z"},{"Instrument":"UT Gage ","ID_No":"UT-02","NextDueDate":"2019-06-25T00:00:00.000Z"}]]

вот данные JSON:


[
[
{
Instrument: "Coating Thickness Gauge",
ID_No: "BG-05",
NextDueDate: "2019-10-17T00:00:00.000Z"
},
{
Instrument: "Coating Thickness Gauge",
ID_No: "BG-06",
NextDueDate: "2019-10-17T00:00:00.000Z"
},
{
Instrument: "Coating Thickness Gauge",
ID_No: "BG-07",
NextDueDate: "2019-10-17T00:00:00.000Z"
},
{
Instrument: "Coating Thickness Gauge",
ID_No: "BG-09",
NextDueDate: "2019-09-15T00:00:00.000Z"
},
{
Instrument: "Coating Thickness Gauge",
ID_No: "BG-10",
NextDueDate: "2019-09-15T00:00:00.000Z"
},
{
Instrument: "Coating Thickness Standards",
ID_No: "TS-04",
NextDueDate: "2019-09-01T00:00:00.000Z"
},
{
Instrument: "Deep Freezer",
ID_No: "LE-05",
NextDueDate: "2019-11-07T00:00:00.000Z"
},
{
Instrument: "DSC Tester ",
ID_No: "LE-04",
NextDueDate: "2019-09-17T00:00:00.000Z"
},
{
Instrument: "Freezer ",
ID_No: "LE-11",
NextDueDate: "2019-11-07T00:00:00.000Z"
},
{
Instrument: "Holiday Detector ",
ID_No: "HD-349",
NextDueDate: "2019-11-20T00:00:00.000Z"
},
{
Instrument: "Holiday Detector ",
ID_No: "HD-488",
NextDueDate: "2019-10-15T00:00:00.000Z"
},
{
Instrument: "Jeep Meter ",
ID_No: "JM-02",
NextDueDate: "2019-09-26T00:00:00.000Z"
},
{
Instrument: "Lab Oven ",
ID_No: "LE-09",
NextDueDate: "2019-11-07T00:00:00.000Z"
},
{
Instrument: "Lab Oven (CDT) ",
ID_No: "LE-06",
NextDueDate: "2019-11-07T00:00:00.000Z"
},
{
Instrument: "Microscope",
ID_No: "LE-01",
NextDueDate: "2019-11-07T00:00:00.000Z"
},
{
Instrument: "Pit Gauge",
ID_No: "PG-10",
NextDueDate: "2019-09-25T00:00:00.000Z"
},
{
Instrument: "Pit Gauge",
ID_No: "PG-11",
NextDueDate: "2019-09-27T00:00:00.000Z"
},
{
Instrument: "Pit Gauge",
ID_No: "PG-12",
NextDueDate: "2019-08-18T00:00:00.000Z"
},
{
Instrument: "Salt Contamination Meter",
ID_No: "TM-01",
NextDueDate: "2019-08-24T00:00:00.000Z"
},
{
Instrument: "UT Gage ",
ID_No: "UT-02",
NextDueDate: "2019-06-25T00:00:00.000Z"
}
]
]

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...