import {cryptoData, cryptoAssets} from "./data.js";

export function fakeFetchCrypto() {
    return new Promise(resolve => {
        setTimeout(() => {
            resolve(cryptoData)
        }, 2000)
    })
        .then(function (response) {
            return response.json();
        })
        .then(function (data) {
            console.log(data);
            return data;
        })
        .catch(function (error) {
            console.log('Ошибка:', error);
        });
}

export function fetchAssets() {
    return new Promise(resolve => {
        setTimeout(() => {
            resolve(cryptoAssets)
        }, 2000)
    })
}

export async function fetchUsers() {
    return (fetch('http://localhost:8000/api/users', {
        method: "GET"
})
    .then(function (res) {
            return res.json();
    })
    .then(function (data) {
        console.log(data);
        return data;
    })
    .catch(function (err) {
        console.log('Ошибка:', err);
    })
    )
}

