Recommendations Service
Explore how to create a recommendations service for an Angular event page, implement feature toggling, and unit test HTTP requests using mocked JSON responses. Understand setting up HttpClient and writing success and error tests to ensure reliable API integration in your app development process.
We'll cover the following...
At this point, we’re ready to add the final feature to our event view page, which displays a list of restaurant recommendations to the user. This list of recommendations will only be displayed if the event creator sets the “Suggest Locations” radio button to “Yes.” If they select “No,” the view for this feature will be hidden.
Recommendations service
Start by generating a new service for restaurant recommendations.
ng g service services/recommendations/recommendations
From there, we’ll create a new testing directory and a file within it.
mkdir src/app/testing
touch src/app/testing/recommendations-result.json
The first command ng g service services/recommendations/recommendat ...