import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { School } from './../../app/component/school'

@Injectable()
export class DistrictProvider {

    public districtAPI = 'https://data.delaware.gov/api/views/wky5-77bt/rows.json?accessType=DOWNLOAD'

    constructor(public http: HttpClient) {
            console.log('Hello DistrictProvider Provider');

    }

    getAllSchools() {

        return this.http.get(this.districtAPI) //.map((response: any) => {
            // if (response.data.length > 0) {
            //     return response.data[0].images.original.url;
            // } else {
            //     return console.log('error');
        //     }
        // });
    }

    parseData(data: any) {
        return data["data"].map(school => new School(school[13]))
    }


}