import { client } from "./HttpClient";
import axios from 'axios';
import { Config } from 'react-native-config';

class UserController {
  static async login(email, password) {
    
    //console.log("controller",Config.API_URL)
    // client.post('http://ec2-3-82-143-53.compute-1.amazonaws.com:86/api/v1/user/login', {
    //   "emailid":"ujjwal@sentientgeeks.com",
    //   "Password":"123456"
    // })
    // .then(function (response) {
    //   console.log(response);
    // })

  //   fetch('https://reqres.in/api/users?page=2', {
  //     method: 'get',
  //     headers: { 'Content-Type': 'application/json' },
  
  // }).then(response => response.json())
  //     .then(data => {
  //         console.log("data", data)
  //     })
  //     .catch(error => { console.log(error) })

  

    return new Promise((resolve, reject) => {
      // if (email && password) {
      //   setTimeout(() => resolve({ name: 'Jorge' }), 1000);
      // } else {
      //   setTimeout(() => reject(new Error('Invalid Email/Password')), 1000);
      // }
      axios.get('https://reqres.in/api/users?page=2')
  .then((response) => {
    console.log(response)
    resolve(response)
  }, (error) => {
    console.log(error)
    reject(new Error(error))
  });
    });
  }

  static async logout() {
    console.log("logout from controller")
    return new Promise(resolve => {
      setTimeout(resolve, 1000);
    });
  }
}

export default UserController;
