To create an app that shows the latest news using the Guardian API.
The app will grab the headlines from the Guardian newspaper API and display them on a page. Clicking on a headline will link the user to the actual article page on the Guardian's website. A search function will allow the user to search for specific articles.
I approached this challenge by using a test driven approach and created the unit tests with Jest:
- Create a domain model and diagram from the user story
- Create a failing test (red) in Jest
- Develop code to result in a passing test (green)
- Refactor the code and re-test (orange)
JavaScript (with esbuild, jest and jest-fetch-mock module) CSS HTML
As a busy politician
So I know what the big stories of the day are
I can see all of today's headlines in one place
As a busy politician
So that I have something nice to look at
I can see a relevant picture to illustrate each news article when I browse headlines
As a busy politician
So I can get a few more details about an important story
I can click a news article title which links to the original article
As a busy politician
So I can search what I want to read about
I can specify a search query on the page and get articles matching this search
git clone the repo
You'll need to register and get an API key to use the Guardian API.
Once you have the API key, please create and save a file in ./src directory named 'ApiKey.js'.
Enter the following within the file: module.exports = 'YOUR KEY HERE';
Whilst in the root directory:
-
Enter 'npm install' in the terminal to install the dependencies.
-
Enter 'npm run build' in the terminal to bundle the JavaScript files.
-
Open the HTMl page via the terminal. Mac: 'open index.html' or Linux: 'google-chome index.html'
Run Jest in the terminal with the 'jest' command from the root directory to test the code.