Skip to content

Instantly share code, notes, and snippets.

@ProbablePrime
Last active February 20, 2017 23:14
Show Gist options
  • Save ProbablePrime/bd1a4d353325a32012e53a68efb402b5 to your computer and use it in GitHub Desktop.
Save ProbablePrime/bd1a4d353325a32012e53a68efb402b5 to your computer and use it in GitHub Desktop.
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