Vue3 does not support parameter assignment

I am working on creating a function that takes two parameters, a string and an array. The array is meant to be filled with data obtained from Axios. However, I am encountering the issue {'assignment' is assigned a value but never used.}. My goal is for the 'this.quizzAllCategories' to be equal to the 'assignment' parameter.

callAPI(params: string, assignment: quizzType[]) {
      axios
        .get(`https://printful.com/test-quiz.php?action=${params}`)
        .then((res) => {
          assignment = res.data;
        });
    },
  },
  async created() {
    await this.callAPI("quizzes", this.quizzAllCategories);
  },

Answer №1

Make sure to retrieve the data by calling the function, rather than assuming the "return variable" will be provided as an additional parameter. It's important to understand how this process functions.

fetchData(data: string) {
  return axios
    .get(`https://example.com/api?action=${data}`)
    .then((response) => {
      return response.data;
    });
},
async getData() {
  this.allData = await this.fetchData("information");
},

Answer №2

ESLint is behaving correctly by flagging that you have declared a variable and assigned it a value, but you are not using it anywhere in your code.

Resolution: The warning will disappear if you use the variable somewhere in your code :)

Another solution (not recommended): You can temporarily disable the rule by adding the following lines before the problematic line of code

// eslint-disable-next-line no-unused-vars

assignment = res.data

/* eslint-enable no-unused-vars */

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

Ensure the browser only reloads a single file

In the midst of my project, I realized that the CSS and JS files are being loaded separately onto the webpage with query strings like .css?1234 to ensure the browsers refresh the files on load. However, upon returning to the project, I discovered that one ...

Creating a parent component within a child component in Vue.js

My application features a key component: export default { name: 'category', props: { ref: Object, asLabel: Boolean }, components: { Products } } The template in the Products component includes: <category :asLabel="tr ...

After successfully authenticating, you may introduce a new React component

Currently, I am working on a page that will only display information once a user has logged into their account. I have successfully implemented an authentication system using NodeJS, and now my goal is to restrict access to specific components or pages bas ...

"Object.entries seems to be returning only the initial object in the list

This is my object var obj = { "first_obj": { "a":1, "status": 1 }, "second_obj": { "a":2, "status": 3 } } I'm struggling to loop through this object using foreach and Object.entries, as the latter only returns the first object. How ...

Tips for Managing Disconnection Issues in Angular 7

My goal is to display the ConnectionLost Component if the network is unavailable and the user attempts to navigate to the next page. However, if there is no network and the user does not take any action (doesn't navigate to the next page), then the c ...

Refresh the current AngularJS page while preserving the stateParams

I am currently working on a function that toggles the display of a button based on data retrieved from an external API. When loading a record, I pass in an 'id' parameter ($stateParams.id) If the value of this parameter is 1, a button will be s ...

React is unable to locate the component element within the DOM

I'm attempting to set the innerHTML for the div element with the ID of ed. Unfortunately, I am unable to access it once React has finished rendering. It seems that this is due to the render stages, as I am receiving a null value for the div element. W ...

Is there a way to locate an element within innerHTML using getElementById?

Is it possible to achieve the following code snippet? <div id="parent"> <iframe id="myFrame" title="HEY!" srcdoc="<div id='inner'>Hello World!</div>"></iframe> </div> v ...

Components in Angular do not refresh after using router.navigate

I currently have two main components in my Angular project: users.components.ts and register.components.ts. The users.components.ts displays a table of users, while the register.components.ts is where users can be added or edited. After making changes to ...

Steps to bring life to your JavaScript counter animation

I need to slow down the counting of values in JavaScript from 0 to 100, so that it takes 3 seconds instead of happening instantly. Can anyone help me with this? <span><span id="counter"> </span> of 100 files</span> <s ...

Interact with the button through Swipe Left and Right gestures

Is it possible to trigger a button click using JQuery or JavaScript when swiping left or right on two buttons like these? <button id="right" type="button">SWIPE RIGHT</button> <button id="left" type="button">SWIPE LEFT</button> If ...

Are toggle functionalities triggered when an element is clicked?

How come the span triggers functions a and b when first clicked, is there a way to set it up so that it calls function a on the first click and then function b on the second click? function a(id) { $.post("url.php", {'id':id}, function() { ...

Utilize the power of Elasticsearch.js along with Bluebird for enhanced performance

Recently delving into node.js, I've been exploring the powerful capabilities of the bluebird promise framework. One of my current challenges involves integrating it with the elasticsearch javascript driver. After some experimentation, I was able to su ...

How to assign multiple selection values in Bootstrap's select picker

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.7.5/css/bootstrap-select ...

The error message "Type 'string[]' does not match type 'string' in NestJS" indicates a type mismatch between a string array and a single

I am attempting to download a file by utilizing an external API in NestJS. Here is the snippet of code from my service: import { Injectable } from '@nestjs/common'; import * as fs from "fs"; import * as axios from "axios"; @Injectable() export cl ...

Having trouble with ajax file upload using jQuery version 1.9.1 and higher?

I am experiencing an issue with my file upload form when using jQuery versions 1.9.1 and above. The form uploads files to Amazon S3 with a generated policy, and while it works perfectly fine with jQuery <=1.9.0, it seems to be broken in the newer versio ...

Upon logging in to the first HTML page, the user will be automatically redirected to the second HTML page while passing values

Is there a way to automatically redirect users to Login2.html when selecting "TEAM" in the dropdown on Login1.html, using the values entered in Login1.html? Similarly, can we redirect them to the Premium page when they select "Premium"? I need a solution u ...

What could be causing the 500 error when receiving images from the API, while all other data is successfully retrieved?

I've encountered a puzzling issue while running my Next.js project. When requesting a photo from the API, I receive a 500 error, whereas other data like price is fetched without any problem. Below is the fetchApi snippet: import axios from "axio ...

Navigating Angular's ng-grid: Utilizing JSON attributes structured with continually increasing integers

Currently, I am facing an issue with populating an ng-grid instance using JSON received from a rest API. In the past, I successfully tested this setup and it was working without any configuration problems. The previous JSON response had a top-level "users" ...

What steps can be taken to prevent a tab click from causing issues?

Within my application, there is a tab group that contains four tabs: <ion-tabs> <ion-tab [root]="tab1Root" tabTitle="Programmes" tabIcon="icon-programmes"></ion-tab> <ion-tab [root]="tab2Root" (ionSelect)="studioCheck()" tabTitle= ...