Not working anymore, because Web-API icndb.com
was disbled?
Simple Angular application to fetch so called Chuck Norris facts (short jokes) from the REST-API provided by icndb.com.
You can try out the application directly here via GitHub Pages.
- Description of REST-API provided by ICNDB
- File ExampleResponseFromRestAPI.json with an example for an response from the REST-API when request asked to return 5 random jokes.
- Article on "Chuck Norris facts" on Wikipedia
- Tutorial on HTTP-GET requests in an Angular application
- Video "Chuck Norris facts read by Chuck Norris" on youtube.com
- Similar API: https://api.chucknorris.io/
Execute command npm run build
to build the application.
The target folder for output of command ng build
was moved to folder docs to enable serving of the generated application via GitHub Pages, see key architect/build/options/outputPath
in file angular.json.
The application has a Web App Manifest, see file src/manifest.json.
This manifest is declared in file angular.json in the array projects/architect/assets
, so
it is also copied to the target folder docs.
This manifest file is referenced by a <link>
in file src/index.html.
The Web App Manifest can be checked in Chome und Chrome-based browsers like Opera in the Developer Tools under "Application | Manifest",
see this screenshot.
The actual loading of the jokes from the REST-API via HTTP is implemented in service class icndb.service.ts. The jokes are not fetched individually, but in batches which are stored in an internal array that acts as queue.
For styling the bootstrap framework is used.
This Angular application can access the REST-API from a different domains than it is served itself because the
HTTP response from the REST-API contains the HTTP header Access-Control-Allow-Origin: *
.
This HTTP header tells most browsers to not block the Ajax request made by this application despite its
violation of the Same Origin Policy.
The favorites are stored in the browser's Local Storage, i.e. stored favorites are available only in the browser installation that was used to save them. The favorites in the Local Storage can be checked in the browser's developer tools; for example, in Chrome und Chrome-based browsers like Opera you have to open the Developer Tools and navigate to "Application | Local Storage", see this screenshot.
See the LICENSE file for license rights and limitations (GPL v3) for the files in this repository.
The author of this application is NEITHER related to The Internet Chuck Norris Database (icndb.com) NOR to Chuck Norris.