I can access database and get data from my Oracle db. But this error occur in my broswer console.
import oracledb from 'oracledb'
oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT
export default async function (ctx) {
let connection
try {
connection = await oracledb.getConnection({
user: 'user',
password: 'user!1',
connectString: '127.0.0.1:1521/uat2'
})
const result = await connection.execute(
`SELECT PAGETITLE, ACTIVITYID
FROM TB_MOULD
WHERE ACTIVITYID = 'WYDJQHD001'`,
[]
)
console.log(result.rows)
} catch (err) {
console.error(err)
} finally {
if (connection) {
try {
await connection.close()
} catch (err) {
console.error(err)
}
}
}
}
I guess that webpack don't distinguish whether node-oracledb can run on non-server side during bundle process. Anyone has solutions?
I has find solution now.
if (process.server) {
const oracledb = require('oracledb')
oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT
//......
}