-1
我試圖在處理上傳的Multer文件後渲染視圖。 我得到了一個錯誤處理後的渲染視圖Express/POST
Unhandled promise rejection (rejection id: 1): TypeError: res.redirect is not a function
做我明白了什麼錯? 還應用從來不知道botom渲染爲 'step2.ejs'
app.post('/vision/upload', upload.single("upl"), function(req, res) {
var file = req.file;
filePath = req.file.path;
const req2 = new vision.Request({
image: new vision.Image(file),
features: [
new vision.Feature('DOCUMENT_TEXT_DETECTION', 10),
]
});
vision.annotate(req2).then((res) => {
p1 = JSON.stringify(res.responses);
p1up = p1.toUpperCase();
occurrencesText = new Occurrences(p1up);
console.log(occurrencesText);
connection.query(queryString, function(err, rows, fields) {
if (err) throw err;
for (var i in rows) {
var occurence = stringOccurrence(p1up, rows[i].name);
var fuzzy = fuzzysearch(rows[i].name, p1up);
if(fuzzy = true){
arrayResults.push([rows[i].name, occurence]);
}
//
}
});
res.render('step2.ejs', {
results: arrayResults,
"filePath": filePath
});
}) });
你是否在自己的某個地方調用'res.redirect()'? – alex
不,唯一的其他res.render(甚至沒有redirec)我有家'route.app.get('/ home',函數(req,res){res.render('uploadform.ejs'); });' –