fix id
This commit is contained in:
@@ -2,7 +2,6 @@ import User from '../../models/User';
|
|||||||
import { connectDB } from '../../lib/utils';
|
import { connectDB } from '../../lib/utils';
|
||||||
|
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
await connectDB();
|
|
||||||
const { userId } = req.query;
|
const { userId } = req.query;
|
||||||
|
|
||||||
console.log('Received request with userId:', userId);
|
console.log('Received request with userId:', userId);
|
||||||
@@ -12,10 +11,12 @@ export default async (req, res) => {
|
|||||||
return res.status(401).json({ message: 'Unauthorized' });
|
return res.status(401).json({ message: 'Unauthorized' });
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = await User.findOne({ clerkId: userId });
|
await connectDB();
|
||||||
|
|
||||||
|
const user = await User.findOne({ id: userId });
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
console.log('User not found for clerkId:', userId);
|
console.log('User not found for userId:', userId);
|
||||||
return res.status(404).json({ message: 'User not found' });
|
return res.status(404).json({ message: 'User not found' });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,4 +34,5 @@ export default async (req, res) => {
|
|||||||
console.log('Method not allowed:', req.method);
|
console.log('Method not allowed:', req.method);
|
||||||
res.status(405).json({ message: 'Method not allowed' });
|
res.status(405).json({ message: 'Method not allowed' });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Reference in New Issue
Block a user