#could you please also look into my code
1 messages · Page 1 of 1 (latest)
you'd need an API route that you can hit, that will import both of those to trigger it to run.
i am using latset verison of next
is that. something like below
// /app/api/users.js
import { sequelize } from '../../database/sequelize.js';
import User from '../../database/models/user';
export default async function handler(req, res) {
if (req.method === 'GET') {
try {
const users = await User.findAll();
res.status(200).send("check")
} catch (error) {
res.status(500).json({ error: 'Internal Server Error' });
}
} else if (req.method === 'POST') {
const { username, email } = req.body;
try {
const newUser = await User.create({ username, email });
res.status(201).send("check")
} catch (error) {
res.status(500).json({ error: 'Internal Server Error' });
}
} else {
res.status(405).json({ error: 'Method Not Allowed' });
}
}
but i went into 404
You could write that a little simpler