Package Exports
- @launchpadlab/lp-requests
- @launchpadlab/lp-requests/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@launchpadlab/lp-requests) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
lp-requests
Promise-based helpers for making HTTP requests.
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.
Relation to axios
lp-requests
serves the exact same function as axios- that is, it provides a thin wrapper around the 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.
Migration Guides
Contribution
This package follows the Opex NPM package guidelines. Please refer to the linked document for information on contributing, testing and versioning.