import { download } from '../../tools/download';
import './download.scss';

let Download = props => {

    let startDownload = e => {
        // fetch('https://api.ourfor.top/blog/essays')
        // .then(res => res.json())
        // .then(res => {
        //     console.log(res);
        //     download(JSON.stringify(res),'essay.json');
        // })

        $.getJSON('https://api.ourfor.top/blog/essays',null,data => {
            download(JSON.stringify(data),'essay.json');
        })
    }

    return (
        <button className="downloader" onClick={startDownload}></button>
    );
}

export { Download };