The absence of FormData.entries in submit is a limitation of the Vue framework

I recently created a Vue-App that consists of a simple form with just one

<input name"surname">
and a
<button type="submit">
.
The use case is to input "myname" and submit the form.

However, when I initialize new FormData() with the submitted form, it does not contain any entries.

// template.html

<form @submit.prevent="handleFormSubmit">
  <input type="text" name="surname" />
  <button type="submit">Save</button>
</form>
// form.ts
...
import tpl from "./template.html"

export default defineComponent({
  template: tpl,
  ...
  methods: {
    handleFormSubmit(event:SubmitEvent)
    {
      console.log(event.target); // log: <form>...</form>
      console.log(event.target.querySelector('input').value); // log: myname
      const formData = new FormData(event.target);
      console.log([...formData.entries()]) // log: []
    }
  } 
})

I'm puzzled as to why new FormData(event.target) is unable to capture the value of my input field. Can anyone shed some light on this issue?

Answer №1

Hey there, one way to solve this issue is by opting for Object.fromEntries(formData) over formData.entries()

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it possible to create tags in Material UI Autocomplete using events other than just pressing the 'Enter' key?

In my current project, I am utilizing the freesolo Autocomplete feature. My specific requirement is to create tags when input text is followed by commas or spaces. Currently, tags are created on the Enter event by Autocomplete, but I am looking for a way t ...

What is the best way to display only a specific container from a page within an IFRAME?

Taking the example into consideration: Imagine a scenario where you have a webpage containing numerous DIVs. Now, the goal is to render a single DIV and its child DIVs within an IFrame. Upon rendering the following code, you'll notice a black box ag ...

`There was an issue with an unfinished string literal.`

Currently, I am utilizing jQuery to display the information from a JSON string generated by PHP and extracted from a database. However, I have encountered an issue where some of the data spans multiple lines... How can I prevent this from triggering an un ...

"Customize your text alignment with TinyMCE's align

I'm in the process of updating from an outdated version of TinyMCE to the most recent release. In the old TinyMCE, if you inserted an image and aligned it to the left, the HTML generated looked like this: < img src="testing.jpg" align="left" > ...

"Effortlessly move elements with HTML5 drag and drop functionality from either direction

I'm working on an application that requires Html5 Drag and Drop functionality, which is currently functioning well. However, in the app, there may be instances where a dropped item is no longer needed and I want to allow users to re-drag and drop it b ...

Utilizing AngularJS to effectively group and filter using Ng-repeat

I am working with an array retrieved from an Azure server Log (clicks array) that I need to sort in a specific way. Below is the request: $http({ method: 'Get', headers: { 'Host': 'api.applicationinsights.io&apo ...

The npm request was unsuccessful due to a self-signed certificate within the certificate chain causing the failure

I am attempting to launch a React Native project using Expo from this site npm install expo -g expo init AwesomeProject npm start However, when running npm start, I encounter the following error: npm ERR! code SELF_SIGNED_CERT_IN_CHAIN npm ERR! er ...

Why are JS & jQuery's inArray() and indexOf() functions not functioning correctly when indexes are strings?

Here is an example of an array: var arr = []; arr['A string'] = '123'; arr['Another string'] = '456'; I am attempting to find the index of either '123' or '456'. Both methods below are returnin ...

Create a table by incorporating the information from the page along with additional content

I need to extract the data from a list and convert it into a table, add some additional content that I will provide, and then align the table accordingly. While I can easily align elements and already have the list, I am facing difficulty in converting it ...

Completion of TypeScript code is not working as expected, the variable that is dependent upon is not

Looking for assistance with creating code completion in TypeScript. Variable.Append1 Variable.Append2 Variable.Append3 I have defined the following class: class Variable { Append1(name: string){ if (name == undefined) ...

Using dynamic mdi svg icons with Vuetify

I'm struggling to display a dynamic v-icon within a v-select component. I want to replace the icon name with its imported value <v-select v-model="data.type" dense :items="typeItems" :label="$tc('Type')"> & ...

The Angular datepicker is failing to trigger the ng-change event

I've run into a snag with the datepicker and ng-change functionality. Oddly enough, the ng-change event isn't triggering when I manually select a date by clicking on it, but it works fine when I input a date manually. Take a look at my code snip ...

Encountering a npm script error while running on a Windows operating

While using webpack to build my application, I encountered the following error message in the command prompt: [email protected] dev D:\Myprograms\java script\forkify webpack --mode development The error mentioned: Insufficient num ...

Is it possible to search LinkedIn using just one keyword?

Is it possible to search for a LinkedIn profile using a single string instead of separate first and last names? The issue is that I only have a single name field in my database... Typically, one would construct a dynamic URL like this: http://www.linkedin ...

What methods are available to test my website across different browsers such as outdated versions of Internet Explorer like IE8?

Currently, I am working on Chrome with Windows 7 OS installed. However, Windows 7 does not support Internet Explorer 8. This is causing issues when trying to view my web pages in the IE8 version and older. How can I resolve this problem? I have attempted ...

Utilizing the layout of nuxt-child over the parent's design

I am currently exploring the world of Nested Routes and <nuxt-child> while working with layouts in nuxt.js. The parent component is housing the <nuxt-child>, giving us a view into the subroutes of the parent. My goal is to have Nuxt utilize t ...

Looking to transform a list into JSON format using JavaScript?

I have a collection that looks like this: <ol class="BasketballPlayers"> <li id="1">Player: LeBron, TotalPoints: 28753, MVP: true</li> <li id="2">Player: Steph, TotalPoints: 17670, MVP: true< ...

Razzle fails to initiate the server

After creating my React project with Razzle.js and downloading it from a repository, I encountered an issue when trying to run it. Upon running yarn start, the screen gets stuck at a message saying the source is compiled and server is running on localhost: ...

JsTree drag and drop feature malfunctioning: Icons disappear when dragging items

I am currently utilizing JsTree with the drag and drop plugin enabled in conjunction with an angular directive, https://github.com/ezraroi/ngJsTree. Everything appears to be functioning correctly, however, when I move a node, it does not visually show as ...

Using PHP script, extract information from a JSON file and populate a dropdown menu in HTML

I am attempting to extract data from a JSON file using PHP and then display this data in an HTML select tag on the front end. Below is my PHP file: <?php ini_set('display-errors', 'on'); error_reporting(E_ALL); $executionStartTim ...