0
const express = require('express');
const cors = require('cors');
const massive = require('massive');
const bodyParser = require('body-parser');
const config = require('../config');
const app = express();
app.use(bodyParser.json());
//massive connection string to database
massive(config.dblink).then(db => {
app.set('db', db)
app.get('db').seed_file().then(res => {
console.log(res)
})
}).catch(err => {
console.log(err)
});
const port = 3001;
app.listen(port,() => {console.log(`the server is listening on ${port}`)})
我收到以下錯誤:我得到一個未處理的承諾拒絕錯誤,但無法弄清楚,爲什麼
(node:173676) UnhandledPromiseRejectionWarning: Unhandled promise rejection
(rejection id: 2): error: syntax error at or near "{"
(node:173676) [DEP0018] DeprecationWarning: Unhandled promise rejections are
deprecated. In the future, promise rejections that are not handled will
terminate the Node.js process with a non-zero exit code.
我一直無法弄清楚什麼是錯的。我查看了多個不同的示例,但看不到問題。在我的seed_file
承諾後,我有一個.catch
。
有什麼想法?
右下方'的console.log(RES)'你有一個額外'})'。刪除,你應該是好的 –
@MarkDodds不是這樣,只是代碼格式不正確 – codtex