Good day
I am trying to use an autocomplete jquery framework.. buy my problem is how can i get my objects either from a json file or just a quick typed json object like the below and get all the Object.values(arry) to a single array like below..
["samue", "anthon", "Harmony", "Johnson"]
and must be an array.. because auto complete frameworks only works with arrays
const myobj = [
{
"name": "samuel",
"surname": "anthony"
},
{
"name": "Harmony",
"surname": "Johnson"
}
]
const file = "json/user.json";
fetch('file')
.then(res => res.json())
.then((data) =>{
let i = 0;
const val = Object.values(data[i]);
if(i < data.length){
i++;
const all = Object.values(data[i]);
console.log(all);
}
var input = document.getElementById("countries");
var awesomplete = new Awesomplete(input, {
minChars: 1,
maxItems: 5,
autoFirst: true
});
awesomplete.list = val;
//wanted array of
//["samuel", "anthon", "school"]
})