Last active
February 20, 2017 23:14
-
-
Save ProbablePrime/bd1a4d353325a32012e53a68efb402b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fetch , { Request, Response, RequestInit } from 'node-fetch'; //tslint:disable-line | |
const fetchCookie: (url: string | Request, init?: RequestInit) => Promise<Response> = require('fetch-cookie')(fetch); //tslint:disable-line | |
const BASE = 'https://beam.pro/api/v1/'; | |
function buildURL(url: string): string { | |
return BASE + url; | |
} | |
export function request(method: string, url: string, body: Object): Promise<Response> { | |
return fetchCookie( | |
buildURL(url), | |
{ | |
method, | |
body: JSON.stringify(body), | |
}, | |
); | |
//.then(res => res.json()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment