Node.js postgress错误:整数“的输入语法无效”&引用;
我在knex中使用了reactjs、nodejs、express和postgress 这是密码Node.js postgress错误:整数“的输入语法无效”&引用;,node.js,reactjs,postgresql,Node.js,Reactjs,Postgresql,我在knex中使用了reactjs、nodejs、express和postgress 这是密码 app.post('/new-story', (req, res) => { const {title, description, mature, id} = req.body; db.select('stories').from('users').where('id' = id) .then(data => { const stories = dat
app.post('/new-story', (req, res) => {
const {title, description, mature, id} = req.body;
db.select('stories').from('users').where('id' = id)
.then(data => {
const stories = data[0].stories;
db('story')
.returning('*')
.insert({
title: title,
category: category,
description: description,
mature: mature,
entry: stories
})
.then(story => {
res.json(story)
})
})
.catch(err => console.log(err))
})
我收到了错误的消息
错误:Connection.parseE处的整数“”的输入语法无效
Connection.parseMessage,位于套接字
这是我的react应用程序中的代码
onSaveDate = () => {
fetch('http://localhost:3001/new-story', {
method: 'post',
header: {'Content-Type' : 'application/json'},
body: JSON.stringify({
id: this.state.id,
title: this.state.title,
description: this.state.description,
category: this.state.category,
mature: this.state.mature
})
})
.then(response => response.json())
.then(story => console.log(story))
}
我试图在postman中测试我的结束点,结果成功了,idk当我在react应用程序中尝试时,它说错误:整数的输入语法无效:“
这是数据库
CREATE TABLE users (
id serial primary key,
name VARCHAR(100),
email text unique not null,
stories bigint default 0,
joined timstamp not null
);
这是我的餐桌故事
CREATE TABLE users (
id_book serial primary key,
entry bigint default 0,
title varchar(100),
category varchar(100),
description varchar(100),
mature varchar(10)
);
我希望故事和条目是一样的,我无法找出postgress节点中的错误,因为我的id列是空的,所以如果有人遇到这样的错误 错误:Connection.parseE处的整数“”的输入语法无效 Connection.parseMessage,位于套接字 您应该检查数据库是否为空