Is it considered good practice to make a POST request while also making a GET request in my app? Or is this frowned upon?
In my application, the functionality works like this: when the page loads, it needs to retrieve user data. If the user data is not found in the database, it should be added. There is no sign-up process involved - we are simply keeping track of all users on the site (tracking how many times they've visited and assigning an ID).
UPDATE: We are not storing login information or signing users up; we are only recording the number of website visits in our database.
I attempted to set it up by first making a GET request and then running a POST request upon success, but it seems overly complicated.
export default function handler(req, res) {
if (req.method === 'GET') {
// check if user exists in db (db.get())
// if not, execute a PUT request (db.save())
}
}