From 3aa51d70b377440897ec3076fa2f7406e0cadcec Mon Sep 17 00:00:00 2001 From: David Pickart Date: Tue, 18 Feb 2020 14:50:52 -0600 Subject: [PATCH] Update readme --- README.md | 38 ++++++++++++++++++++++++++++++++++---- package.json | 2 +- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3641cf2..cfc9071 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,45 @@ # lp-requests -Client-side request helpers. +Promise-based helpers for making HTTP requests. -## Documentation -Documentation and usage info can be found in [docs.md](docs.md). +```js +import { api, configureApi } from '@launchpadlab/lp-requests' + +// Make a request +api + .get('/user', { query: { id: 1 } }) + .then((response) => { + // handle success + }) + .catch((error) => { + // handle error + }) + +// Configure defaults +const externalApi = configureApi({ + root: 'https://my-external-api/', + mode: 'cors', +}) + +externalApi.get('/user', { query: { id: 1 } }) +// -> makes a request to https://my-external-api/user?id=1 +``` + +A full list of available request options may be found in the [documentation](#documentation). + +## Relation to axios +`lp-requests` serves the exact same function as [axios](https://github.com/axios/axios)- that is, it provides a thin wrapper around the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). Once `axios` has become appropriately stable, it may be used as a replacement for `lp-requests`. + +## Documentation + +Documentation and usage info can be found in [docs.md](docs.md). ## Migration Guides -- [v4.0.0](migration-guides/v4.0.0.md) +- [v4.0.0](migration-guides/v4.0.0.md) ## Contribution + This package follows the Opex [NPM package guidelines](https://github.com/LaunchPadLab/opex/blob/master/gists/npm-package-guidelines.md). Please refer to the linked document for information on contributing, testing and versioning. diff --git a/package.json b/package.json index d6b1aab..cbbbad4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@launchpadlab/lp-requests", - "version": "4.1.7", + "version": "4.1.8", "description": "Request helpers", "main": "lib/index.js", "scripts": {