Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
How to assign data from API response to state?

I am retrieving the data from API. But I can't assign that object to the state object in vuex.

HERE IS MY STATE OBJECT

 state: {
    calendarOptions:[],
}

how will I assign data to calendarOptions by api call?

And in My Action

actions: {
//some api call, and its response 

this.state.calendarOptions = response.data

}

i need something like this ?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

in docs of vuex explained how to do that
for changing state you have to use mutations

Example

export default {
    state: {
        calendarOptions:[],
    },
    mutations: {
        setCalendarOptions(state, data) {
            state.calendarOptions = data
        }
    },
    actions: {
       getCalendarOption({commit}) {
           //some api call, and its response 

           commit("setCalendarOptions", response.data)
       }
    }
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!