import axios from 'axios';
export const getHeaders = (token: string) => {
  const headers = {
    Authorization: `Bearer ${token}`,
  };
  return headers;
};
export const getUserDeUna = async (token: string) => {
  try {
    const headers = getHeaders(token);
    const response = await axios.get(
      'http://ec2-3-228-2-53.compute-1.amazonaws.com:3000/allUser',
      { headers: headers }
    );
    return response.data;
  } catch (err: any) {
    console.log(err.response.data);
    return err.response.data;
  }
};
export const getUsuariotoPay = async (token:string,phone:string) => {
  try {
    const headers = getHeaders(token);
    const body={
      "phone":phone
    }
    const response = await axios.post(
      `http://ec2-3-228-2-53.compute-1.amazonaws.com:3000/getUserByPhone`,body,
      { headers: headers }
    );
    if(response.data){
      return response.data;
    }
    throw new Error("no existe datos");
  } catch (err: any) {
    throw new Error(err.response.data);
  }
};
