我想知道如何在Azure中使用Easy API在Azure中進行查詢之後解析結果?對我來說,似乎在函數內部創建一個objet(結果)會導致無限循環,最後返回httpcode 500. 請幫忙。必須有解析結果的方法,將其存儲在一個Javascript對象中,然後將結果作爲Json返回。如何在節點js中解析azure表的結果
var azureMobileApps = require('azure-mobile-apps');
var queries = require('azure-mobile-apps/src/query');
var api = {
get: (req, res, next) => {
if(Object.keys(req.query).length === 0) {
res.status(400).type('text/plain').send("Error! Please add event id");
return;
}
if(req.query.eventId === 'undefined' || req.query.eventId.length === 0) {
res.status(400).type('text/plain').send("Error! missing eventId parameter");
console.log("worked!");
return;
}
var query = {
sql: 'Select .... where [email protected]'
,
parameters: [
{ name: 'eventId', value: req.query.eventId }
]
};
req.azureMobile.data.execute(query)
.then(function (results) {
TODO: here! Parse results, add properties to objects and then return that instead!
res.status(200).type('application/json').send({sessions: results});
},function(error){
console.log('Found an error: ', error);
});
}
};
api.get.access = 'authenticated';
module.exports = api;
嗨,你現在解決了你的問題嗎?如果您有任何更新,請隨時通知我。 –