Skip to content

Latest commit

 

History

History
47 lines (38 loc) · 1.18 KB

createstudent.md

File metadata and controls

47 lines (38 loc) · 1.18 KB

Create a New Student Account


Creates a new student object using information from the request body, along with empty arrays for enrolled classes and transaction history.

Returns the newly created student object

URL Params:

  • None

Data Params:

{
    "firstName": "First Name",
    "lastName": "Last Name",
    "email": "Email Address",
    "uid": "Auto-Generated Unique User ID"
}

Success Response

Status Code: 201 Created

Response Content:

{
    "firstName": "First Name",
    "lastName": "Last Name",
    "email": "Email Address",
    "enrolled_courses": [],
    "transaction_history": [],
    "uid": "Auto-Generated Unique User ID"
}

Error Response

Condition: If request body does not have enough information to create a new student

Status Code: 400 Bad Request

Response Message: Error posting new student. Be sure to include a uid, first_name, last_name, and email.

Sample Call

axios.post("/api/students", student)
.then((res) => console.log(res.data))
.catch((err) => console.error(err));