argument str must be a string
Unanswered
Spectacled bear posted this in #help-forum
Spectacled bearOP
in the following code
located in
I'm getting the following error:
and I cant figure out what the problem is, or rather, where it lies, since the problem is pretty clear
any help please?
import axios from '../../../../lib/api';
import cookie from 'cookie';
export async function GET (req, res) {
if (req.method === 'GET') {
const { token } = cookie.parse(req.headers.cookie);
if (!token) {
res.status(403).json({ message: 'not authorized' });
}
await axios
.get('/api/users/me', {
headers: {
Authorization: `Bearer ${token}`,
}
})
.then((response) => {
return new Response(
res.status(200).json({
user: response.data.username,
email: response.data.email,
id: response.data.id,
})
);
})
.catch((error) => {
return new Response(res.status(403).json({ message: 'not authorized' }));
});
}
};located in
/src/app/api/auth/user/route.jsI'm getting the following error:
⨯ TypeError: argument str must be a string
at Object.parse (webpack-internal:///(rsc)/./node_modules/cookie/index.js:35:15)
at GET (webpack-internal:///(rsc)/./src/app/api/auth/user/route.js:11:63and I cant figure out what the problem is, or rather, where it lies, since the problem is pretty clear
any help please?