The type 'Readonly<Ref<Readonly<any>>>' does not have the property 'forEach' available

Having an issue with state management in Vue3 (Pinia) using the Composition API. I successfully retrieved an array called countryCodes and now I want to copy all items from this array into another array called countries defined in the state. However, when trying to clone the array using forEach method and other methods, I encounter the error "Property 'forEach' does not exist on type 'Readonly<Ref<Readonly>>'". Please note that I am using TypeScript. How can I resolve this error?

export const getAllCityAndCountries = defineStore("main", {
  state: () => {
    return {
      countries: [
        {
          code: '880',
          name: 'Bangladesh',
          emoji: '🇧🇩'
        }
      ]
    }
  },
  actions: {
    getCountries() {
      const { result, error } = useQuery(gql`${getCountryCodes}`, 
        {
          limit: 250,
          skip: 0
        }

      )
      let countryCodes = useResult(result, null, data => data.getCountryCodes.result.countryCodes)

      countryCodes.forEach(val => this.countries.push(Object.assign({}, val)));
    },

  }

})

Answer â„–1

The useResult function provides a ref. To retrieve its value, use countryCodes.value

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 modify the CSS injected by an Angular Directive?

Is there a way to override the CSS generated by an Angular directive? Take, for instance, when we apply the sort directive to the material data table. This can result in issues like altering the layout of the column header. Attempting to override the CSS ...

Refreshing Form in VueJs Form Builder app

I've developed a dynamic form using VueJs form generator. By simply clicking buttons like textBox or text area, I can update an array of model and schema and utilize it in the following manner: var fromControlRules = new Vue({ el: '#form&apo ...

Ways to invoke a slice reducer from a library rather than a React component

I've been working on a React application using the React Boilerplate CRA Template as my foundation. This boilerplate utilizes Redux with slices, which is great for updating state within a React component. However, I'm facing a challenge when try ...

Dropdown with multiple selections closes after making only one selection

Currently, I have a multi-select dropdown feature where users can list and select multiple items at once. Here is the code snippet I am utilizing for this functionality: <Multiselect v-model="abc" valueProp="x ...

How to effectively utilize multiple Vue instances in your project?

My inquiry is somewhat linked to a similar question on Stack Overflow, but I am uncertain about the level of discouragement towards the approach discussed in relation to Vue. In my situation, I am working on a project where the DOM is generated entirely b ...

Issue with MomentJS inBetween function consistently displaying incorrect results

I'm currently working on Vue Datatable and I have a specific requirement to search for records between two dates. I am using the moment.js library and the inBetween function to achieve this. Strangely, when I hardcode the dates, the function returns t ...

I am attempting to make the fade in and out effect function properly in my slideshow

I've encountered an issue where the fading effect only occurs when the page initially loads and solely on the first image. Subsequently, the fading effect does not work on any other images displayed. This is the CSS code I have implemented by adding ...

Step-by-step guide on programmatically activating a radio button

I am working with a radio button and input field. I need the ability to programmatically toggle the radio button so that when this.iAreaOfCoverageForThresholdPasser.average-height is set to true, the radio button appears highlighted. Snippet of HTML: < ...

Error: User authentication failed: username: `name` field is mandatory

While developing the backend of my app, I have integrated mongoose and Next.js. My current challenge is implementing a push function to add a new user to the database. As I am still relatively new to using mongoose, especially with typescript, I am followi ...

Definition in TypeScript: specify a type or interface containing a field with an unidentified name

Looking to define an interface for a team object: export interface Team{ memberUid?: { mail: string name: string photoURL: string } startDate: Timestamp endDate: Timestamp agenda: Array<{ date: Date | Timestamp title: strin ...

Tips for triggering the update of index.view when the Save command is triggered within an active dialog

When I try to save in an open dialog using the Save command, the parent index.view does not update. However, everything works fine when using the SaveAndClose command. This was tested on the Product object at https://github.com/alex-kukhtin/A2v10.Web.Sampl ...

Can the Rxjs library's Observables of() function be used to output multiple values?

I am inquiring about this because I came across in the Angular documentation that of(HEROES) returns an Observable<Hero[]> which emits a single value - an array of mock heroes. If I cannot use of(), do you have any alternative suggestions for me? I ...

Create a function that takes in a function as an argument and generates a new function that is identical to the original function, except it has one

I want to establish a function called outerFn that takes another function (referred to as innerFn) as a parameter. The innerFn function should expect an object argument with a mandatory user parameter. The main purpose of outerFn is to return a new functio ...

What is the reason behind Angular's repeat filter only being able to access its own element within the return function?

I have successfully implemented some Angular code that is working, however, I am struggling to understand why it works. Coming from a C Sharp background and being new to JS and Typescript. <tr ng-repeat="colleague in Model.FilteredColleagueListModel | ...

Enable a VueJS directive on-the-fly from a separate directive

My goal is to simplify the process of binding a form control to vuejs by creating a directive that handles all necessary events for tracking changes in a form field. Rather than manually adding multiple event listeners like this: <input type="text" na ...

Nano frontend program

My current project consists of 5 different single-page applications (SPAs): 2 in Angular, 2 in React, and 1 in Vue.js. These SPAs are served by an integrated server that handles routing for each one. I am looking for a way to share data between these app ...

Can a class be attached to an element depending on a boolean condition?

Is there a way to bind a class to an element based on the result of a boolean expression in Vue.js? Here's an example of what I'm trying to achieve: <input type="email" :class="{ invalid: submitted && $v.email.$error }"> However, ...

Updating the text area value based on the selected option in a dropdown using Typescript within Angular6

I'm currently facing an issue with updating the text area value based on the selection from a dropdown menu. Below is the design of the dialog: https://i.sstatic.net/67U1M.png Here's the code snippet I've incorporated for this functionalit ...

Troubleshooting the compatibility issue of HTML5 video tag on iOS Safari browser (iPhone)

Scenario I encountered an issue while trying to play a video in the Edge browser. The project framework consists of: .NET 6 MVC and VUE for the client side .NET 6 WebApi for the server side The Vue component on the client will send a request with ...

What is the best way to enable code sharing between two TypeScript projects housed within the same repository?

Our project has the following structure: api (dir) -- package.json -- tsconfig.json -- src (dir) -- client (dir) ---- package.json ---- tsconfig.json ---- src (dir) The "client" directory houses a create-react-app project that proxies to the API d ...