I am trying to return an array of surnames from a json query to form part of a section which can be chosen by a user.
$.ajax({
url: 'https://reqres.in/api/users?page=1',
type: "GET",
success: function (response) {
console.log(response);
original = convState.current;
State.current.next = State.newState({
type: 'select',
question: ['Please select'],
answer: [{text: [response.data[0].last_name], value: 'true'}],
});
The current result only returns the one surname bluth from the json which can be found at https://reqres.in/api/users?page=1
If I try and add a loop to access the array, absolutely nothing happens. The html page just waits for something to happen, which never happens. Can some please help met rectify the loop, I am not sure where and how I should add it. I tried here, but then the page waits for nothing to ever happen.
var len = data.length;
for(var i=0;i<len;i++){
answer: [{text: [response.data[i].last_name], value: 'true'}],
}