当我尝试在我的应用上提交信息时,我与Heroku有错误。 我正在按照文档中的步骤进行操作:https://trailhead.salesforce.com/en/project/quickstart-heroku-connect/qs-heroku-connect-4
我运行服务器,我在提交按钮上然后在我的术语上得到:
{ [Error: connect ETIMEDOUT 54.228.214.47:5432]
code: 'ETIMEDOUT',
errno: 'ETIMEDOUT',
syscall: 'connect',
address: '54.228.214.47',
port: 5432 }
/home/f.freitag/workspace/radiant-dusk-13720/server.js:17
conn.query(
TypeError: Cannot read property 'query' of null
at /home/f.freitag/workspace/radiant-dusk-13720/server.js:17:13
at /home/f.freitag/workspace/radiant-dusk-13720/node_modules/pg/lib/pool.js:82:27
at /home/f.freitag/workspace/radiant-dusk-13720/node_modules/pg/node_modules/generic-pool/lib/generic-pool.js:339:9
at /home/f.freitag/workspace/radiant-dusk-13720/node_modules/pg/lib/pool.js:31:28
at null.<anonymous> (/home/f.freitag/workspace/radiant-dusk-13720/node_modules/pg/lib/client.js:176:5)
at emitOne (events.js:77:13)
at emit (events.js:169:7)
at Socket.<anonymous> (/home/f.freitag/workspace/radiant-dusk-13720/node_modules/pg/lib/connection.js:59:10)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
npm ERR! Linux 2.6.32-504.12.2.el6.x86_64
npm ERR! argv "/usr/local/node/bin/node" "/usr/local/node/bin/npm" "start"
npm ERR! node v4.5.0
npm ERR! npm v2.15.9
npm ERR! code ELIFECYCLE
npm ERR! phone-change@0.0.0 start: `node server.js`
npm ERR! Exit status 1
npm ERR! Failed at the phone-change@0.0.0 start script 'node server.js'.
npm ERR! This is most likely a problem with the phone-change package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs phone-change
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls phone-change
npm ERR! There is likely additional logging output above.
我试图在谷歌上看到这个问题,但我一无所获。另外,我不是nodeJS程序员,它可能很简单。 我没有改变git clone中的代码。
这是来自server.js的代码。我对行错误
发表评论var express = require('express');
var bodyParser = require('body-parser');
var pg = require('pg');
var app = express();
app.set('port', process.env.PORT || 5000);
app.use(express.static('public'));
app.use(bodyParser.json());
app.post('/update', function(req, res) {
pg.connect(process.env.DATABASE_URL, function (err, conn, done) {
if (err) console.log(err);
conn.query( //the error
'UPDATE salesforce.Contact SET Phone = $1, HomePhone = $1, MobilePhone = $1 WHERE LOWER(FirstName) = LOWER($2) AND LOWER(LastName) = LOWER($3) AND LOWER(Email) = LOWER($4)',
[req.body.phone.trim(), req.body.firstName.trim(), req.body.lastName.trim(), req.body.email.trim()],
function(err, result) {
done();
if (err) {
res.status(400).json({error: err.message});
}
else {
res.json(result);
}
});
}
else {
done();
res.json(result);
}
}
);
});
app.listen(app.get('port'), function () {
console.log('Express server listening on port ' + app.get('port'));
});
答案 0 :(得分:0)
问题出在Heroku Connect映射上。由于在查询中添加了新字段,因此您还需要更新在Contact
对象的Heroku Connect初始设置过程中所做的映射。
步骤:
Contact
的映射。HomePhone
并保存。完成上述步骤后,重新运行应用程序,现在应该看到HomePhone
字段值与Phone
相同。