-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Dashbrd/add-service-layer
added service layer
- Loading branch information
Showing
5 changed files
with
54 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { StarWarsCharacter } from './star-wars-character.model'; | ||
|
||
export interface ApiResponse { | ||
count: number; | ||
next: string; | ||
previous?: any; | ||
results: StarWarsCharacter[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { SwapiService } from './swapi.service'; | ||
|
||
describe('SwapiService', () => { | ||
beforeEach(() => TestBed.configureTestingModule({})); | ||
|
||
it('should be created', () => { | ||
const service: SwapiService = TestBed.get(SwapiService); | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ApiResponse } from '../models/api-response.model'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Injectable } from '@angular/core'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class SwapiService { | ||
|
||
constructor(private httpClient: HttpClient) { | ||
|
||
} | ||
|
||
getPeople() { | ||
return this.httpClient.get<ApiResponse>('https://swapi.co/api/people'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters