Hello, I'm using Nexst.js I'm a junior front-end developer.
To access the DB API I also configured API for next Failed to get the token value stored in the cookie I'd appreciate it if you could tell me how
The file below is Present in src/pages/api
const getOrder = async (token, order_no) => {
return await
fetch(`${process.env.NEXT_PUBLIC_API_HOST}/front/order/${order_no}`, {
headers: {
Authorization: `Bearer ${token}`,
Accept: "application/json"
}
}).then(res => res.json()).then(data => data)
}
export default async function handler(req, res) {
const { order_no } = req.query
const token = "How do I access cookies????"
const order = await getOrder(token, order_no)
try {
res.status(200).json({ ...order })
} } catch (err) {
res.status(200).json({ err })
}
}
req.cookies를 이용하세요
In P.S. JavaScript, the variable name is camelCase such as orderNo
.
snake_case such as order_no
is used in languages such as Python, so we recommend you to change it.
Of course, if that's the case with the convention set by the place you belong, you should do it, and it's a personal project, so I don't mind using it if you really want to, but I told you the general case.
590 Understanding How to Configure Google API Key
671 GDB gets version error when attempting to debug with the Presense SDK (IDE)
591 Who developed the "avformat-59.dll" that comes with FFmpeg?
596 PHP ssh2_scp_send fails to send files as intended
586 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.