I'm looking for a way to have mock data in a CONST or in a .json file when I'm not working without my backend services or network.
For the moment I use my services :
get_clubs(): Observable<Club[]> {
return this.http.get(`${this.config.apiEndpoint}clubs`, options)
.map((res: Response) => res.json())
.catch((error: any) => 'doing stuff';
};
The ${this.config.apiEndpoint}
is my URL defined in my app.config.ts as a global constant (found here)
And I started to create some CONST files (user.mock.ts) :
export const CLUBS: Club[] = [
{
"_id": "...",
"name": "..."
},
{
...
}
];
Sometimes I can't reach my backend and I want to pick data from my CONST or my .json files.
Do you have any clues about that ?