I am struggling to create a for loop to iterate through my array efficiently.
Below is the code snippet that I have and its functionality explained.
export class BookingService {
private config: Object;
public domainSettings: Object = {};
constructor(
private http: Http,
private kioskservice: KioskService
) { }
public getAllBookings() {
return new Promise((resolve, reject) => {
this.http
.get(
`${this.kioskservice.getAPIUrl()}search/dashboard/${this.kioskservice.LocationGUID()}/?apikey=${this.kioskservice.getAPIKey()}&format=json&from=2018-04-17&until=2018-04-18&full=true`
)
.toPromise()
.then(
res => {
this.config = res.json()
console.log(res.json());
resolve();
},
msg => {
throw new Error("Couldn't get all Bookings: " + msg);
}
);
});
}
The above code fetches an array from an HTTP request made to the API. Here is an example of the returned array :
(2) [{…}, {…}]
0
:
AssignedUserProfile
:
null
BookUserGuid
:
"221443aa-d3c7-4543-b858-6a8710904ff8"
BookingRequestGuid
:
null
BookingStates
:
[{…}]
Channel
:
"Private"
CheckCancelAllowed
:
{Result: "BookingCancelDateInPast", Price: null}
CheckEditAllowed
:
{Result: "BookingSaveTimeStartDateInPastError", Price: null}
Coordinates
:
null
Culture
:
"nl-NL"
Customer
:
{Guid: "f2791b53-9db0-4e86-99c0-8f25c1242e72", Reference: null, Name: " test", DirectUrl: "https://dev.api.timeblockr.local/v2/userprofiles/f2791b53-9db0-4e86-99c0-8f25c1242e72"}
CustomerGuid
:
"f2791b53-9db0-4e86-99c0-8f25c1242e72"
...
I am looking to iterate through the arrays and extract the "TicketNumber" field to create a list of Ticket numbers instead of displaying the entire arrays. Can anyone provide guidance on how to achieve this using a for loop?