I'm new to vuejs
and I want to display my data response in a two-dimensional table.
This is the data I have:
[{
"origine": "",
"nb": 15
}, {
"origine": "?",
"nb": 18
}, {
"origine": "?L",
"nb": 1
}, {
"origine": "G",
"nb": 298
}, {
"origine": "I",
"nb": 51
}, {
"origine": "L",
"nb": 1735
}, {
"origine": "L?",
"nb": 1
}, {
"origine": "O",
"nb": 4
}]
After mapping, I would like the data structure to be either of these formats:
[
['', 15],
['?', 18],
['?L', 1],
['G', 298],
['I', 51],
['L', 1735],
['L?', 1],
['O', 4]
]
Or like this :
[
'': 15,
'?': 18,
'?L': 1,
'G': 298,
'I': 51,
'L': 1735,
'L?': 1,
'O': 4
]
Here is what I've tried so far:
getResultcivitas(localisation) {
axios
.get('../api/civitasorigine/' + this.searchInputcivitas)
.then(response => {this.origines = response.data.map (x => x.origine)})
}
I found the following code snippet but unsure how to apply it in my axios query.
map = origines.map(obj => {
var rObj = {};
rObj[obj.origine] = obj.nb;
return rObj;
});