Javascript 我的heroku应用程序不是';heroku没有拿到postgresDB
我在heroku上部署了React应用程序,还添加了postgres模块,但我在前端没有获得任何数据,而我可以在后端的控制台上修改所有内容 我的代码:Javascript 我的heroku应用程序不是';heroku没有拿到postgresDB,javascript,node.js,reactjs,postgresql,heroku,Javascript,Node.js,Reactjs,Postgresql,Heroku,我在heroku上部署了React应用程序,还添加了postgres模块,但我在前端没有获得任何数据,而我可以在后端的控制台上修改所有内容 我的代码: // this is the DB config: const { text } = require("express"); let pg = require("pg"); if (process.env.DATABASE_URL) { pg.defaults.ssl = true; } // in
// this is the DB config:
const { text } = require("express");
let pg = require("pg");
if (process.env.DATABASE_URL) {
pg.defaults.ssl = true;
}
// include an OR statement if you switch between a local dev db and
// a remote heroku environment
let connString =
process.env.DATABASE_URL ||
process.env.PG_HOST;
const { Pool } = require("pg");
const pool = new Pool({
connectionString: connString,
});
module.exports = {
query: (text, params) => pool.query(text, params),
};
当我记录DATABASE_URL变量时,我得到了未定义的结果。请帮忙 是否将
数据库\u URL
添加到Heroku应用程序的配置变量部分?您可以在Heroku仪表板的设置页面中查看它。Harshana Serasinghe,是的,看起来或多或少像这样:postgres://:42987404ec@ec2-23-20-168-40.compute-1.amazonaws.com:5432/d24qet9lga6fnu
// this is the axios config
import axios from 'axios';
export default axios.create({
baseURL: process.env.DATABASE_URL + '/api/v1/restaurants',
})