Log in

This endpoint is going to give back a Bearer Token to authenticate in all our endpoints.

https://api.exchangecopter.com/api/login

POST

import axios from "axios";

/**
 * logIn - Sends a GET request to authenticate with the API.
 * 
 * This method sends the `username` and `password` as query parameters 
 * to retrieve an authentication token from the provided URL.
 * 
 * @returns {void} Logs the token to the console or an error if the request fails.
 */
const logIn = async () => {
  const username = "username";
  const password = "password";
  const credentials = btoa(`${username}:${password}`);

  // Request configuration
  const config = {
    method: 'post',
    maxBodyLength: Infinity,
    url: "https://api.exchangecopter.com/api/login",
    headers: { 
      'Content-Type': 'application/json'
    },
    body: { credentials }
  };

  // Perform the request and handle the response
  try {
    const response = await axios.request(config);
    console.log(response.data.token); // Logs the token to the console
  } catch (error) {
    console.error("Authentication error:", error); // Logs the error in case of failure
  }
};

Responses

👍

Status 200

{
    "token": "bearerTokenHere"
}

❗️

Status 401

{
    "message": "Las credenciales son incorrectas o es una ip no registrada."
}