'API resolved without sending a response for /api/user, this may result in stalled requests. in Next JS API
Here is my code in NEXT JS API. I'm currently using mysql on next js api
const pool = require('../../src/config/database')
export default function handler(req, res) {
console.log(req.body.user)
if (req.method == 'POST') {
try {
pool.query(
`SELECT * FROM users WHERE email=?`,
[req.body.user],
async (error, results, fields) => {
console.log(results)
console.log(error)
await results ? res.status(200).send(results) : res.status(404).send({ success: false })
}
)
} catch (err) {
res.status(500).send('something went wrong!')
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
