Deployment Heroku节点部署错误&;postgresql
我试图使用heroku进行部署,但出现以下错误: 整数类型的输入语法无效:“favicon.ico” 我一直在寻找信息,但据我所知,这与我分配给数据库的数据类型有关吗 database.sql:Deployment Heroku节点部署错误&;postgresql,deployment,heroku-postgres,Deployment,Heroku Postgres,我试图使用heroku进行部署,但出现以下错误: 整数类型的输入语法无效:“favicon.ico” 我一直在寻找信息,但据我所知,这与我分配给数据库的数据类型有关吗 database.sql: -- CREATE DATABASE freenutrition; --\c food CREATE TABLE food ( food_id SERIAL PRIMARY KEY, name VARCHAR(25), type VARCHAR(20), weight
-- CREATE DATABASE freenutrition;
--\c food
CREATE TABLE food (
food_id SERIAL PRIMARY KEY,
name VARCHAR(25),
type VARCHAR(20),
weight_int int,
prot real,
lip real,
hc real,
n_int_card int,
img_link VARCHAR(200)
);
db.js
package.json
{
"name": "backend-freenutrition",
"version": "1.0.0",
"description": "",
"main": "index.js",
"engines": {
"node": "15.8.0",
"npm": "7.5.1"
},
"scripts": {
"start": "node index.js"
},
"author": "JGP",
"license": "ISC",
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"pg": "^8.5.1"
}
}
index.js(路由之一)
{
"name": "backend-freenutrition",
"version": "1.0.0",
"description": "",
"main": "index.js",
"engines": {
"node": "15.8.0",
"npm": "7.5.1"
},
"scripts": {
"start": "node index.js"
},
"author": "JGP",
"license": "ISC",
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"pg": "^8.5.1"
}
}
//ROUTES//
//create a food
app.post("/", async (req, res) => {
try {
const { name, type, weight_int, prot, lip, hc, n_int_card, img_link } = req.body;
const newFood = await pool.query(
"INSERT INTO food (name, type, weight_int, prot, lip, hc, n_int_card, img_link) VALUES($1,$2,$3,$4,$5,$6,$7,$8) RETURNING *",
[name, type, weight_int, prot, lip, hc, n_int_card, img_link]
);
res.json(newFood.rows[0]);
} catch (err) {
console.log(err.message);
}
});
//get all foods
app.get("/", async (req, res) => {
try {
const allFoods = await pool.query("SELECT * FROM food");
res.json(allFoods.rows);
} catch (err) {
console.error(err.message);
}
});
```