在我的Azure App Service Node.js后端中,我似乎无法运行Javascript async / await功能。我在应用程序设置中有changed the default version of Node.js,在package.json中有7.6以上。 (更改为8.9.0)
我想在此处显示的自定义Express路由器中使用此功能:
Sub AddFormula_ManualFlag()
Dim rng As Range
Dim ws1, ws2 As Worksheet
Dim result As String
Set ws1 = ThisWorkbook.Sheets("Manual Flags")
Set ws2 = ThisWorkbook.Sheets("ContractOrganization")
Set rng = ws2.Range("L2")
On Error Resume Next 'add this because if value is not found, vlookup fails, you get 1004
result = "=IFERROR(VLOOKUP(ws2.Range("E2"),ws1.Range("$F$2:$L$902").Value,7,0),"""")"
rng.Formula = result
End Sub
尝试使用上述路由器启动应用程序会产生以下结果:
var express = require('express'),
bodyParser = require('body-parser');
var router = express.Router();
router.get('/', function (req, res, next) {
res.status(200).send('GET: This is a test response!');
});
router.post('/:id', async function (req, res, next) {
var context = req.azureMobile;
var newLovedOne = req.body.lovedone;
var newTie = req.body.tie;
console.log('POST: newLovedOne ', newLovedOne);
console.log('POST: newTie ', newTie);
try {
await context.tables('Tie').insert(newTie);
await context.tables('LovedOne').insert(newLovedOne);
} catch (error) {
res.status(500).send('Insert failed!');
}
});
module.exports = router;
答案 0 :(得分:2)
要验证Node.js版本是否已正确设置,您可以转到root并打开iisnode.yml
文件。确保它具有正确版本的以下行:
nodeProcessCommandLine: "D:\Program Files (x86)\nodejs\8.9.0\node.exe"