import { People } from './sw-people.model';
interface Results {
count: Number,
next: String,
previous: string,
results: People[],
}
@Injectable()
export class SwPeopleService {
people$ = this.http.get('https://swapi.co/api/people/')
.map((res: Results) => {
return res.results.sort((a: People, b: People) => {
return a.name === "Darth Vader" ? -1 : b.name === "Darth Vader" ? 1 : 0;
});
});
constructor(private http: HttpClient) {}
}