Error: Unable to access 'subTree' property of null value

Can you help me understand this error?

error message

I encountered this issue when I inserted my filteredData variable within the tr tag of the table.

  <table id="table">
    <tr>
      <th>First name</th>
      <th>Last Name</th>
      <th>Email</th>
      <th>Original email</th>
      <th>Actions</th>
    </tr>
    <template>
      <tr v-if="(fiteredData = '')">
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
      </tr>
      <tr
        v-else
        v-for="data in filteredData"
        :key="data.ind_id"
        :value="data.ind_id"
      >
        <td>{{ data.first_name }}</td>
        <td>{{ data.last_name }}</td>
        <td>{{ data.email }}</td>
        <td>{{ data.email }}</td>
        <td>
          <button @click="sendProps(data)">
            <i class="fa-regular fa-edit" aria-hidden="true"></i>
          </button>
        </td>
      </tr>
    </template>
  </table>

This is how my method looks like:

  data() {
    return {
      fetchedData: "",
      filteredData: "",
    };
  },
  methods: {
    searchResult(e) {
      this.filteredData = this.fetchedData.filter((data) => {
        return data.email.toLowerCase().includes(this.email.toLowerCase());
      });
      e.preventDefault();
      console.log(this.filteredData);
    }

The fetchedData retrieves data from here:

  async mounted() {
    await axios.get("http://localhost:5000/individuals").then((result) => {
      this.fetchedData = result.data;
      console.log(this.fetchedData);
    });
  },

Answer №1

My suggestion is to change this line:

<tr v-if="(filteredData = '')">
to:
<tr v-if="filteredData === ''">
, or perhaps even better:
v-if="!filteredData.length"
. It seems like there was a typo in the variable name and instead of comparing values, it was set to an empty string (we've all been there, I'm sure).

Additionally, it would be more appropriate to initialize fetchedData and filteredData as empty arrays rather than strings, since v-for is designed to iterate over objects and arrays, not strings (even though it might still work with strings).

Answer №2

In my previous experience, I came across this issue where the browser was causing troubles. The solution was to open my application in a new incognito window.

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 split the legend for a Highstock double yAxis?

Is it possible to have a distinct legend for each yAxis when they are split in highstock? I am using a stacked bar chart with the same data series running on both yAxes, resulting in duplicated entries in the legend at the top. Can the legend be divided in ...

Internet Explorer 11 XHR Troubles

Our company has successfully developed a JavaScript video player that can be embedded on various websites using a script tag. As part of the bootstrapping process, we utilize XMLHttpRequest to fetch resources from our server. This creates cross-origin requ ...

Combining Multiple NodeLists in Javascript

Initially, I was seeking a sophisticated method to replicate the functionality of Array.concat() on the results of the getElementsByTagName function in older browsers like IE because it appeared that concat wasn't supported. However, as it turns out, ...

Ways to change the role link in child elements inherited from the parent in terms of Accessibility

How can I create a tooltip with dynamically added tooltip content div requiring a role link for the aria label to be appended as needed? The initial HTML of the tooltip before expansion is: <div class="tooltip" tabindex="0" aria-expa ...

What is the process for building .ts components within a Vue application?

Looking to update an old project that currently uses the 'av-ts' plugin and vue-ts-loader to compile .ts files as Vue components. The project is running on Vue 2.4.2, but I want to upgrade it to version 2.6.14. However, since 'vue-ts-loader& ...

The Model.findOneAndRemove() method has been updated and can no longer accept a callback function, resulting in

const express = require('express') const mongoose = require('mongoose') var app = express() var Data = require('./noteSchema') mongoose.connect('mongodb://localhost/newDB') mongoose.connection.once("open" ...

Encountering an unknown symbol '''' while trying to import a JSX file into a JavaScript file in a React application

Looking for some help with my JSX file, here's a snippet: Selector.jsx import React, { Component } from 'react'; import FormControl from '@material-ui/core/FormControl'; import InputLabel from '@material-ui/core/InputLabel&a ...

Using Jquery $.ajax may lead to temporary freezing of the Browser

I have a $ajax function that fetches multiple JSON objects from a URL and converts them into divs. There are around 50 objects, and I am using setInterval to call the $ajax function every 10 seconds for updates on each of the created divs. However, I' ...

What methods can be used to accurately display the data type with TypeOf()?

When working with the following code: const data = Observable.from([{name: 'Alice', age: 25}, {name: 'Bob', age: 35}]); console.log(typeof(data)); The type is displayed as Object(). Is there a way to obtain more specific information? ...

Placing JavaScript at the bottom of the page, sourced from a Partial Page

I'm trying to display JavaScript code from a Razor Partial Page at the bottom of a (layout) Page. In a similar discussion on Stack Overflow about Including JavaScript at bottom of page, from Partial Views, it was suggested by user Becuzz that using a ...

When selecting a different file after initially choosing one, the Javascript file upload event will return e.target as null

Currently, I have implemented file uploading using <input>. However, when attempting to change the file after already selecting one, the website crashes and states that event.target is null. <Button label="Upload S3 File"> <input ...

Pause and continue scrolling through the page with the push of a button

I have a question about a simple demo. I am looking to prevent scrolling when button1 is clicked, and then resume scrolling when button2 is clicked. Can someone guide me on how to achieve this? Check out the Fiddle here HTML: <input type='button& ...

Preview functionality is disabled in the iOS share extension

Currently, I'm developing a share extension for Safari on iOS. Our approach involves utilizing the default UI provided by iOS and extending the SLComposeServiceViewController class. In addition to this, I have incorporated a JavaScript function to ext ...

Tips on reducing the number of "$routeProvider.when" statements in a complex application

Is there a more efficient way to handle routing in AngularJS, specifically for loading html templates based on $location.path? My current approach involves a long list of "Whens" that will become unmanageable as my application grows. .config(['$rout ...

Struggling to click on a dynamic link before it times out

Can someone help me with a puzzling issue I can't seem to solve? I am trying to achieve the following: Whenever a link is clicked (for example: mysite.com/blog/blog-article.html), I want to save the href of that link to a variable. Then, in JavaScri ...

Visit the map only after the promises have been fulfilled

In my current project, I am utilizing the loadash map function for data structuring. The data retrieved consists of a series of IDs that require querying the database and integrating the results into the map before returning. However, the data is delayed i ...

How can we utilize the Next.js pages router to efficiently import code that should be executed on the client side?

I am incorporating Google Maps into my project using the @googlemaps/extended-component-library library. You can find more information about this library here. import '@googlemaps/extended-component-library/api_loader.js'; import '@googl ...

The rule 'import/no-cycle' definition could not be located

After removing my npm package along with the package.lock.json file, I proceeded to run 'npm install' and followed up with 'npm update'. However, upon starting my application using 'npm run start', an error occurred. Upon lau ...

Use the `string.replace()` method to swap out strings in a nested object with values from a separate file

Is there a way to swap out the placeholders __fruit_type__, __clothing_type__, __fitness_equipment__, __meditation_app__ in collection.js with the corresponding values from values.js? I'm attempting to do this using the string.replace() Method co ...

Ensure Vue line chart stays current with data passed in as props

Vue 2.x chart-js: 2.x vue-chartjs: 3.x I am currently working on a project where I need to send data from a websocket in my parent component to a child component to create a dynamic line chart that updates in real-time. In my Parent.vue file: <templ ...