Conditional API Responses for JavaScript vs. HTML Forms

Today, I’ll show you how to detect whether an HTTP request was submitted via HTML form or with JavaScript to the server.

The examples in this post are based on Nuxt.js and include references to a few global functions (defineEventHandler, getRequestHeaders, sendRedirect). It’s not important that you know how they work. Just focus on the concept. I’ll explicitly highlight the important bits

CategoriesUncategorized