Comparing version 0.0.17 to 0.0.18
@@ -0,1 +1,7 @@ | ||
## [0.0.18](https://github.com/posva/mande/compare/v0.0.17...v0.0.18) (2020-07-28) | ||
### Bug Fixes | ||
- **types:** correct nuxt types + docs ([5d08bdb](https://github.com/posva/mande/commit/5d08bdb61c6199daa6d75caf9a0332cf9bc7ff9a)) | ||
## [0.0.17](https://github.com/posva/mande/compare/v0.0.16...v0.0.17) (2020-07-27) | ||
@@ -2,0 +8,0 @@ |
/*! | ||
* mande v0.0.16 | ||
* mande v0.0.17 | ||
* (c) 2020 Eduardo San Martin Morote | ||
@@ -4,0 +4,0 @@ * @license MIT |
/*! | ||
* mande v0.0.16 | ||
* mande v0.0.17 | ||
* (c) 2020 Eduardo San Martin Morote | ||
@@ -4,0 +4,0 @@ * @license MIT |
/*! | ||
* mande v0.0.16 | ||
* mande v0.0.17 | ||
* (c) 2020 Eduardo San Martin Morote | ||
@@ -4,0 +4,0 @@ * @license MIT |
/*! | ||
* mande v0.0.16 | ||
* mande v0.0.17 | ||
* (c) 2020 Eduardo San Martin Morote | ||
@@ -4,0 +4,0 @@ * @license MIT |
/*! | ||
* mande v0.0.16 | ||
* mande v0.0.17 | ||
* (c) 2020 Eduardo San Martin Morote | ||
@@ -4,0 +4,0 @@ * @license MIT |
{ | ||
"name": "mande", | ||
"version": "0.0.17", | ||
"version": "0.0.18", | ||
"description": "Some awesome description", | ||
@@ -5,0 +5,0 @@ "main": "dist/mande.common.js", |
@@ -113,13 +113,4 @@ # mande [![Build Status](https://badgen.net/circleci/github/posva/mande/master)](https://circleci.com/gh/posva/mande) [![npm package](https://badgen.net/npm/v/mande)](https://www.npmjs.com/package/mande) [![coverage](https://badgen.net/codecov/c/github/posva/mande/master)](https://codecov.io/github/posva/mande) [![thanks](https://badgen.net/badge/thanks/♥/pink)](https://github.com/posva/thanks) | ||
## Nuxt | ||
## SSR (and Nuxt in Universal mode) | ||
Automatically proxy cookies and headers on the server. | ||
```js | ||
// nuxt.config.js | ||
module.exports = { | ||
buildModules: ['mande/nuxt'] | ||
} | ||
``` | ||
To make Mande work on Server, make sure to provide a `fetch` polyfill and to use full URLs and not absolute URLs starting with `/`. For example, using `node-fetch`, you can do: | ||
@@ -132,4 +123,4 @@ | ||
: 'https://example.com' | ||
// on client, do not add the domain, so urls end up like `/api/something` | ||
: '' | ||
: // on client, do not add the domain, so urls end up like `/api/something` | ||
'' | ||
@@ -140,2 +131,34 @@ const fetchPolyfill = process.server ? require('node-fetch') : fetch | ||
### Nuxt | ||
When using with Nuxt **and SSR**, you must wrap exported functions so they automatically proxy cookies and headers on the server: | ||
```js | ||
const fetchPolyfill = process.server ? require('node-fetch') : fetch | ||
const users = mande(BASE_URL + '/api/users', {}, fetchPolyfill) | ||
export const getUserById = nuxtWrap(users, (api, id: string) => api.get(id)) | ||
``` | ||
Make sure to add it as a buildModule as well: | ||
```js | ||
// nuxt.config.js | ||
module.exports = { | ||
buildModules: ['mande/nuxt'], | ||
} | ||
``` | ||
This prevents requests from accidentally sharing headers or bearer tokens. | ||
#### TypeScript | ||
Make sure to include `mande/nuxt` in your `tsconfig.json`: | ||
```json | ||
{ | ||
"types": ["@types/node", "@nuxt/types", "mande/nuxt"] | ||
} | ||
``` | ||
## API | ||
@@ -153,2 +176,1 @@ | ||
[MIT](http://opensource.org/licenses/MIT) | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34138
173
12
561