utilities.ts 573 Bytes
Newer Older
Zac Wood's avatar
Zac Wood committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import * as FileSaver from 'file-saver';

export const ENDPOINTS = {
    generateCalendar: 'http:localhost:3000/api/generate',
};

export function postData(endpoint: string, data: any): Promise<Response> {
    return fetch(endpoint, {
        method: 'POST',
        body: JSON.stringify(data),
        headers: {
            'Content-Type': 'application/json',
        },
    });
}

export function downloadCalendar(calendarText: string) {
    const blob = new Blob([calendarText], { type: 'text/plain;charset=utf-8' });
    FileSaver.saveAs(blob, 'GMU Fall 2018.ics');
}