# Conditional API Responses For JavaScript vs. HTML Forms

DevFeed: [Conditional API Responses For JavaScript vs. HTML Forms](<https://devfeed.tech/articles/conditional-api-responses-for-javascript-vs-html-forms-17712.md>)

Original publisher: [Read original article](<https://austingil.com/http-javascript-vs-html/>)

Author: Austin

Published: 2023-01-03T15:31:38Z

Content type: tutorial

Language: en

Sources: [Back End - Austin Gil](<https://devfeed.tech/sources/back-end-austin-gil.md>)

Topics: [Nuxt.js](<https://devfeed.tech/topics/nuxt.md>), [API](<https://devfeed.tech/topics/api.md>), [Back end](<https://devfeed.tech/topics/backend.md>), [HTTP](<https://devfeed.tech/topics/http.md>), [JavaScript](<https://devfeed.tech/topics/javascript.md>), [Forms](<https://devfeed.tech/topics/forms.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [back-end](<https://devfeed.tech/tags/back-end.md>), [backend](<https://devfeed.tech/tags/backend.md>), [building](<https://devfeed.tech/tags/building.md>), [coding](<https://devfeed.tech/tags/coding.md>), [development](<https://devfeed.tech/tags/development.md>), [edge-compute](<https://devfeed.tech/tags/edge-compute.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [html](<https://devfeed.tech/tags/html.md>), [http](<https://devfeed.tech/tags/http.md>), [idea](<https://devfeed.tech/tags/idea.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [js](<https://devfeed.tech/tags/js.md>), [programming](<https://devfeed.tech/tags/programming.md>), [software](<https://devfeed.tech/tags/software.md>), [web-development](<https://devfeed.tech/tags/web-development.md>)

## AI overview

A tutorial on detecting whether an HTTP request came from an HTML form or JavaScript in a Nuxt.js backend API. It explains returning redirects for form submissions and JSON for JavaScript requests, supporting progressive enhancement when JavaScript fails.

## Source excerpt

Learn how to build backend APIs that support progressive enhancement by detecting if a request was submitted with HTML forms or JavaScript.