Git Product home page Git Product logo

randomprofile's Introduction

Assignments(Structure of the routes file would look like what is given at the bottom of the document): You have to write a POST api: Write the api in first project directory (Routes/index.js or routes/route.js) Problem Statement : NOTE: you must create the players array outside( on the top ) of the api( so that data is maintained across api hits ) Your player collection should be an ARRAY of player objects. Each player object should have the following attributes: { "name": "manish", "dob": "1/1/1995", "gender": "male", "city": "jalandhar", "sports": [ "swimming" ] } e.g. the players array would look like this: let players =    [        {            "name": "manish",            "dob": "1/1/1995",            "gender": "male",            "city": "jalandhar",            "sports": [                "swimming"            ],        },        {            "name": "gopal",            "dob": "1/09/1995",            "gender": "male",            "city": "delhi",            "sports": [                "soccer"            ]        },        {            "name": "lokesh",            "dob": "1/1/1990",            "gender": "male",            "city": "mumbai",            "sports": [                "soccer"            ]        },    ]   Write a POST /players api that creates a new player ( that saves a player’s details and doesn’t allow saving the data of a player with a name that already exists in the data)

NOTE: you must create the players array outside( on the top ) of the api( so that data is maintained across api hits)

—----------------

The file inside routes would look like this:

const express = require('express'); const router = express.Router();   let players =    [        {            "name": "manish",            "dob": "1/1/1995",            "gender": "male",            "city": "jalandhar",            "sports": [                "swimming"            ]        },        {            "name": "gopal",            "dob": "1/09/1995",            "gender": "male",            "city": "delhi",            "sports": [                "soccer"            ]        },        {            "name": "lokesh",            "dob": "1/1/1990",            "gender": "male",            "city": "mumbai",            "sports": [                "soccer"            ]        },    ]      router.post('/players', function (req, res) {          //LOGIC WILL COME HER        res.send(  { data: players , status: true }  )    })       module.exports = router;

HW: https://docs.google.com/document/d/1Q1bkf_ruL3qGYOO-rINkVX62GR4Czy_HO6uy1P_9lhM/edit

randomprofile's People

Contributors

sahilkumargit avatar sabiha-thorium avatar pritesh-h avatar functionup-sk avatar sabihak89 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.