The Objective of this assignment is to work with ReST API's , understand asynchronous programming and build interactive web pages using Javascript.
- Fork this boilerplate repository
- Clone the boilerplate repository and cd into it
- Install dependencies. The idea here is to use json-server to serve static pages and data for movies.
npm install
npm run start or json-server db.json -s ./public
- All your HTML code resides in public/index.html
- All your JavaScript code resides in the public/js folder
- All your CSS code resides in the public/css folder
- All your images resides in the public/images folder
- HTML, Javascript, CSS code should be well indented and commented
- You shall use Bootstrap to style your pages and elements
- The Assignment should be pushed to gitlab on completion and submitted for Preliminary Automated Review as described below.
- Populate data for Movies collection in db.json while another Favourites collection could be left empty initially.
- Create Two Sections/List Movies and Favourites in your HTML page.
- Movies and the Favourites section of the page should populate all the movies and favourites from the db.json using AJAX calls.
- Every Movie item should have a Add to Favourites button.
- On click of the Add to Favourites button the copy of the movie item should be moved to the Favourites list/section. The movie added to Favourites section should also be added to the Favourites collection of db.json using AJAX calls.
- Each movie item in db.json to have atleast
id
,title
,posterPath
- It is mandatory to use Fetch API and Promises for all the HTTP calls
public/js/script.js
is expected to have three functions -
a.getMovies()
- to fetch movies fromhttp://localhost:3000/movies
, populate them in DOM under<ul id="moviesList">
and returns a promise with the JSON response from API
b.getFavourites()
- to fetch favourites fromhttp://localhost:3000/favourites
, populate them in DOM under<ul id="favouritesList">
and returns a promise with the JSON response from API
c.addFavourite()
- as the click event handler for the buttonAdd to Favourites
corresponding to each movie listed underMovies
on page, this shall takeid
of a movie as input, copy the respective movie toFavourites
section, post the movie to db.json viahttp://localhost:3000/favourites
and returns a promise with the complete list of favourites been loaded on the pagepublic/index.html
- Movies list to be populated under<ul id="moviesList">
and Favourites list to be populated under<ul id="favouritesList">
,getMovies()
andgetFavourites()
to be invoked as shown in the file- Test cases for the assignment shall be found in
./test
directory which validates the solution and you shall ensure that all of them pass locally before you submit your code for an automated review (steps shared below)
To run test cases locally, you shall execute -
npm install
(if not done already)
npm run test
- You shall also fix any eslint errors if present in code. To run eslint check locally, you shall execute
npm run eslint
- Once you have fixed all test cases and eslint errors locally, you shall submit your solution for the automated review as described below.
- Open https://hobbes-nht.stackroute.in/#/ and login into the platform
- Under Assignment repository select
javascript-movie-cruiser-assignment
, and branch master - Under Your solution repository select your own repository and branch
- Press Submit
- Press click here for the feedback
- Evaluation will take around 2 mins to complete after which you need to refresh your browser and get the updated status
- Watch out for your total score and detailed status on each test and eslint errors in the coloured blocks on the screen
- Fix failing test cases as well as eslint errors and re-submit your solution until you get 100%
-
You add the respective Mentor as a Reporter/Master into your Assignment Repository
-
You have checked your Assignment on the Automated Evaluation Tool - Hobbes (Check for necessary steps in your Boilerplate - README.md file. ) and got the required score - Check with your mentor about the Score you must achieve before it is accepted for Manual Submission.
-
Intimate your Mentor on Slack and/or Send an Email to [email protected] - with your Git URL - Once you are done working and are ready for final submission.