The functionality of toLowerCase localeCompare is restricted in NuxtJs VueJs Framework

Encountered a peculiar issue in NuxtJs (VueJs Framework).

I previously had code that successfully displayed my stores in alphabetical order with a search filter. When I tried to replicate the same functionality for categories, everything seemed to be working fine. However, the next day, while the categories page worked flawlessly, the stores page threw two errors:

Cannot read property 'localeCompare' of undefined

Cannot read property 'toLowerCase' of undefined

I'm puzzled as to what caused this error, considering the code is identical on both pages; the only difference lies in the data loaded for stores and categories. Removing both localeCompare & toLowerCase seems to resolve the issue, but it disrupts the search filter functionality and list ordering. Below is an excerpt from my code:

<script>
import axios from "axios";

export default {
asyncData({ req, params }) {
return axios.get(process.env.apiURL + "stores").then(res => {
return { 
stores: res.data
};
});
},
data() {
return {
apiURL: process.env.apiURL,
active: null,
search: "",
Searched: "",
filterStores: [],
storeList:['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
}
},
methods: {
filterStore(n) {
this.tab = n;
axios.get(process.env.apiURL + 'stores?filter[where][store_name][regexp]=^\\b' + this.tab + '/i').then(res => {
return this.filterStores = res.data;
});
}
},
computed: {
AllStores: function() {
return this.stores.filter(store => {
return store.store_name.toLowerCase().includes(this.search.toLowerCase())
})
}
},
head: {
title: "Stores"
}
};
</script>
<template>
&vt;v-container grid-list-md text-xs-center>

&vt;v-text-field append-icon="search" v-model="search" id="filter" name="filter" 
label="Search Your Favorite Store . . . ." auto-grow autofocus dont-fill-mask-blanks solo>
&vt;/v-text-field>
&vt;<br/>

&vt;v-tabs grow dark color="teal accent-4" show-arrows slider-color="white">

&vt;<v-tab active>#</v-tab>
&vt;<v-tab v-for="n in storeList" :key="n" ripple @click="filterStore(n)">{{ n }}</v-tab>

&vt;<v-tab-item>    
&vt;<v-layout row wrap>
&vt;<v-flex v-for="(store, index) in AllStores" :key="index" xs6 sm4 md2 lg2 xl3>
&vt;<v-card light>
&vt;<nuxt-link :to="'/store/'+store.store_name">
&vt;<v-card-media :src="`${apiURL}containers` + `${store.store_image}`" height="80px"></v-card-media>
&vt;<v-card-text class="blue">{{store.store_name}}</v-card-text>
&vt;</nuxt-link>
&vt;</v-card>
&vt;</v-flex>
&vt;</v-layout>
&vt;</v-tab-item> 

&vt;<br/>
&vt;<v-layout row wrap>
&vt;<v-flex v-if="filterStores != ''" v-for="(store, index) in filterStores" :key="index" xs6 sm4 md2 lg2 xl3>
&vt;<v-card light>
&vt;<nuxt-link :to="'/store/'+store.store_name">
&vt;<v-card-media :src="`${apiURL}containers` + `${store.store_image}`" height="80px"></v-card-media>
&vt;<v-card-text class="blue">{{store.store_name}}</v-card-text>
&vt;</nuxt-link>
&vt;</v-card>
&vt;</v-flex>
&vt;<v-flex v-else>No Stores Available starting with this letter</v-flex>
&vt;</v-layout>

&vt;</v-container>  
&vt;</template>

Answer №1

After updating my Vue CLI and reinstalling the modules, everything started working smoothly. Grateful for the assistance!

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 place a list/accordion above a button in Semantic UI?

Check out this rough code sandbox here There seems to be an issue with the accordion overflowing behind the button on the left side. I attempted to add style={{position: 'absolute', bottom:'2%', overflow: 'scroll'}} to the A ...

What is the best way to incorporate an npm module in a django-admin widget without the need to install node?

Background I am working on a Django app and need to create an admin widget. The widget will display text in a unique terminal-style format to show forwarded logs from an analytics process managed by Django (using the django-twined extension). To achieve ...

What are the steps to successfully deploy a static website created with Next.js on Vercel?

Using the Next.js static site generator, I created a simple static site that I now want to deploy on Vercel. However, I keep encountering an error during the build process. While I have successfully deployed this site on other static hosting platforms befo ...

Tips for retrieving the user-input value from an HTML text field

Exploring the world of JS, I set out to create a basic calculator after just one week of lessons. However, I hit a roadblock when trying to extract user-input values from my HTML text fields. Here's a snippet of my html: <div class="conta ...

Unable to create a new user account

I have been working on developing an e-commerce platform using the MERN stack, but I have encountered an issue with registering new users. The system only allows me to register the first user successfully after clearing the database, but subsequent registr ...

Automatically generated bizarre URL parameters

Something strange is happening all of a sudden. I've noticed unusual URL parameters appearing on the site, and I'm not sure where they are coming from in my code. https://i.stack.imgur.com/g1xGG.png I am using Webpack 4 and Vue. This issue is ...

The margin on the right side is not functioning as expected and exceeds the boundary, even though the container is using the flex display property

I'm struggling to position the rating stars on the right side without them going outside of the block. I attempted using 'display: flex' on the parent element, but it didn't solve the issue(( Currently trying to adjust the layout of t ...

I aim to trigger a Redux action utilizing react-router-dom

In light of a route adjustment, I am in search of an improved method for invoking the redux action. One option is to invoke a redux action through the render function, as shown below: render(){ const filterName = this.props.match.params.product this.p ...

What is the process for retrieving prop details when making a GET API request in VUE 3?

Hey there! I am currently diving into learning VUE 3 with the router but I'm struggling to grasp how to fetch data based on an id. Can anyone help me out? Every time I check my console log, it keeps showing undefined as the result. What am I doing wr ...

Access any nested node within a JSON/JS object by specifying the key's value

After spending hours searching on various forums for a solution to my problem, I have yet to find one that directly addresses the issue I am facing. So, please take a moment to review the details below. The object structure in question is as follows: let ...

Service in Angular2+ that broadcasts notifications to multiple components and aggregates results for evaluation

My objective is to develop a service that, when invoked, triggers an event and waits for subscribers to return data. Once all subscribers have responded to the event, the component that initiated the service call can proceed with their feedback. I explore ...

Obtaining the MasterTableView Edit Form within a Radgrid to acquire a reference to a textbox

Can anyone help me with two things, please? I am struggling to access the currently edited existing row in the Radgrid and also the index of the Edit form when attempting to add a new record to the table. function OnClientSelectedIndexChanged(sen ...

What is the best way to hide a <tr> element when its child <td> elements are empty?

I am facing an issue with a dynamically generated table that may have 'n' rows. If all <td> elements within a <tr> are empty, I want to hide or delete the entire row. My challenge lies in parsing through each <td> element to ch ...

Determine the status of a script in PHP by incorporating AJAX

I am having trouble with my file upload page in the application. I want to display "Uploading" while the file is uploading and then show "Processing" while the file is being processed. Eventually, after the script completes, my page should redirect to a sp ...

When dynamically adding an option, the select value becomes empty

I am facing a problem with a select element that I cannot change programmatically. Initially, the select has only one option: The initial HTML structure looks like this: <select id="clients" name="client"> <option>Existing Clients...</ ...

The object for checking Ajax connections is not providing any values

I've been working on creating a unique AJAX connection check object, but unfortunately I'm struggling to get it to function properly. :/ Here's the object structure: function Connection(data){ this.isConnected = false, this.check = funct ...

Why does the UseEffect hook in next.js result in 2 fetch requests instead of the expected 1?

I am encountering an issue where my code is triggering two requests to my API using the GET endpoint. Unfortunately, my understanding of useEffect() is not deep enough to pinpoint where the problem lies. I want to avoid putting unnecessary strain on the ...

Using Passport authentication callback rather than redirecting the user

passport.authenticate('local-register',{ successRedirect: '/login', failureRedirect: '/path_to_greatness', })(req, res, next); In the process of developing a stateless API, I have encountered l ...

Encountering a PHP error in Laravel Vapor when attempting to upload a file from the front-end

Oops! Some key environment variables are missing: AWS_BUCKET, AWS_DEFAULT_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY I am utilizing the Laravel Vapor library to handle file uploads from the front-end due to large file sizes (6.8mb). Below is my cod ...

Data transmission from Node's hosted router to an external API, not from Node's hosted API

Need a Node router that can POST Json to a remote API? I dedicated my morning to solving this issue, and now I want to share some detailed examples with you for your benefit. In each example below, the router includes a GET method that, when called, will ...