Answer the question
In order to leave comments, you need to log in
How to write part of an array in vue?
I make an API request and
get the following response:$.get('/api/v2/staff/role/' + this.roleData.id)
{
"id": "1",
"status": "1",
"name": "Администратор",
"rights": {
"orders.view": "1",
"orders.create": "1",
"orders.changeClosed": "0",
"main.managerList": "1",
"main.workerList": "1",
"finance.reports": "1",
"compendiums.counteragents": "1",
"compendiums.works": "1"
},
"error": {
"error_code": 0
}
}
data:{
test: null,
modalAdd: false,
roleData:{
id:null,
name: null,
checkRights: []
}
}
Answer the question
In order to leave comments, you need to log in
const response = {
"id": "1",
"status": "1",
"name": "Администратор",
"rights": {
"orders.view": "1",
"orders.create": "1",
"orders.changeClosed": "0",
"main.managerList": "1",
"main.workerList": "1",
"finance.reports": "1",
"compendiums.counteragents": "1",
"compendiums.works": "1"
},
"error": {
"error_code": 0
}
};
const roleData = {
checkRights: []
};
const rights = Object.keys(response.rights).filter((key) => +response.rights[key] === 1);
roleData.checkRights = roleData.checkRights.concat(rights);
console.log(roleData);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question