I am in a bit of a pickle.
I have an api I am using: https://api.myjson.com/bins/1gb9tf
and an angular component here:
import { Component } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
results: string[];
// Inject HttpClient into your component or service.
constructor(private http: HttpClient) {}
ngOnInit(): void {
// Making the HTTP Request
this.http
.get('https://api.myjson.com/bins/1gb9tf')
.subscribe(data => {
// Read the result field from the JSON response.
this.results = data['results'];
console.log(data);
})
}
title = 'app';
}
with the html being:
<!-- Search Form -->
<form class="" action="index.html" method="post">
<h1> Let's Go. </h1>
<hr>
<select class="" name="">
<option value="">Select means of Travel</option>
<option value="">Flight</option>
</select>
<label for="Travel Start Date">Travel Start Date</label>
<input type="date" name="" value="Travel Start Date">
<label for="Travel End Date">Travel End Date</label>
<input type="date" name="" value="Travel End Date">
<select class="" name="">
<option value="">Departure Location</option>
<option value="">Atlanta</option>
</select>
<select class="" name="">
<option value="">Arrival Location</option>
<option value="">San Francisco</option>
</select>
<select class="" name="">
<option value="">Product Class</option>
<option value="">Economy</option>
</select>
<input style="width: 100px; background-color: green; color: #eef; height: 40px; border-radius: 50px; margin: 0 auto; margin-top: 50px;"
type="submit" name="" value="Submit">
</form>
<!-- Results -->
<div class="result">
{{ results }}
</div>
I am basically trying to pull in the data from the API, and display it in the input fields, ect. Mostly I just need help with looping through the array of objects in the api
Have a great day !