Skip to content

Login endpoint

Alvin Cheng edited this page Apr 23, 2023 · 3 revisions

Description

The login endpoint is used to authenticate the user for Chill&chat, this endpoint will search the MongoDB database and find the user and compare the password. The endpoint will return a status '200' on success, '400' on incorrect user credentials, '401' on invalid API key or '500' on a server processing error. You can find the endpoint's source in /src/endpoints/login.ts. Furthermore, the endpoint will take 2 arguments including, 'username ' which is the username inputted from the user. And the self-explanatory 'password' argument takes the password given.

Example

post("http://<URL>/api/login?key=<YOUR_API_KEY>", {
  username: "<USERNAME>",
  password: "<PASSWORD>",
})
  .then((res) => {
    console.log(res);
  })
  .catch((err) => {
    console.error(err);
  });

Clone this wiki locally