Skip to content

Instantly share code, notes, and snippets.

@stuf
Created April 29, 2017 06:57
Show Gist options
  • Save stuf/385beab9af0f0aa2b7267340fa7a65a0 to your computer and use it in GitHub Desktop.
Save stuf/385beab9af0f0aa2b7267340fa7a65a0 to your computer and use it in GitHub Desktop.
import axios from 'axios';
import * as L from 'partial.lenses';
import * as U from 'karet.util';
import Kefir from 'kefir';
const baseURL = 'http://localhost:3004';
const client = axios.create({ baseURL });
export const request$ = req => Kefir.fromPromise(client(req));
export const request = req => U.seq(req,
U.flatMapLatest(request$),
U.view(L.props('status', 'headers', 'data')));
// Shorthands
export const get$ = (url, headers = {}) => request({ method: 'GET', url, headers });
export const post$ = (url, data) => request({ method: 'POST', url, data });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment