Я хочу вставить строки в таблицу:
router.post('/insertAllAccessible', function(req, res) {
// récupération des organisations accessibles
connexion.query("select organisation_id, id_tag_ip, organisation_lib from organisation where is_accessible = 1", (err, rows, fields) => {
if (err) {
throw err;
}
for(var d=0; d<rows.length; d++) {
var json = rows[d];
idOrganisations.push(json.id_tag_ip);
}
});
request({
headers: req.body,
url: "https://api.tag-ip.com/track/fleets",
json: true
}, function (error, response, body) {
if (!error && response.statusCode == 200) {
var flottes = body.data;
for(var f=0; f<flottes.length; f++) {
var flotteJSON = flottes[f];
var relationshipsJSON = flotteJSON.relationships;
var organizationJSON = relationshipsJSON.organization;
var dataJSON = organizationJSON.data;
var attributesJSON = flotteJSON.attributes;
// filtrage des flottes selon les organisations accessibles
if ( idOrganisations.includes(dataJSON.id) ) {
var oFlotte = {"organisation_id":"(select organisation_id from organisation where id_tag_ip = '"+dataJSON.id+"')",
"flotte_tag_ip_id":dataJSON.id,
"flotte_libelle":attributesJSON.name,
"flotte_description":attributesJSON.description};
connexion.query("insert into flotte set ?", oFlotte, function(err, rows) {
if (err) throw err;
}
);
}
}
}
}
);
}
);
Во время выполнения это вызывает ошибки! Так что не так?