mirror of
https://github.com/strapi/strapi.git
synced 2025-08-26 17:53:10 +00:00
Merge branch 'master' into add-overlay-blocker
This commit is contained in:
commit
c6a0d0afbf
@ -12,10 +12,10 @@ The most advanced open-source Content Management Framework to build powerful API
|
||||
|
||||
{% endcenter %}
|
||||
|
||||
## v3@alpha.7 is available!
|
||||
## v3@alpha.8 is available!
|
||||
We've been working on a major update for Strapi during the past months, rewriting the core framework and the dashboard.
|
||||
|
||||
This documentation is only related to Strapi v3@alpha.7 ([v1 documentation is still available](http://strapi.io/documentation/1.x.x)).
|
||||
This documentation is only related to Strapi v3@alpha.8 ([v1 documentation is still available](http://strapi.io/documentation/1.x.x)).
|
||||
|
||||
**[Get Started](getting-started/installation.md)**<br />
|
||||
Learn how to install Strapi and start developing your API.
|
||||
@ -36,4 +36,3 @@ Understand how to develop your own plugin.
|
||||
Learn about Strapi's API, the `strapi` object that is available in your backend.
|
||||
|
||||
**[Migration guide](migration/migration-guide.md)**<br />
|
||||
Migrate from v1 to v3@alpha.7.
|
||||
|
@ -2,6 +2,63 @@
|
||||
|
||||
Strapi provides helpers so you don't have to develop again and again the same generic functions.
|
||||
|
||||
## Auth
|
||||
|
||||
`auth.js` lets you get, set and delete data in either the browser's `localStorage` or `sessionStorage`.
|
||||
|
||||
### Methods
|
||||
|
||||
| Name | Description |
|
||||
| ---- | ----------- |
|
||||
| clear(key) | Remove the data in either `localStorage` or `sessionStorage` |
|
||||
| clearAppStorage() | Remove all data from both storage |
|
||||
| clearToken() | Remove the user's `jwt Token` in the appropriate browser's storage |
|
||||
| clearUserInfo() | Remove the user's info from storage |
|
||||
| get(key) | Get the item in the browser's storage |
|
||||
| getToken() | Get the user's `jwtToken` |
|
||||
| getUserInfo() | Get the user's infos |
|
||||
| set(value, key, isLocalStorage) | Set an item in the `sessionStorage`. If `true` is passed as the 3rd parameter it sets the value in the `localStorage` |
|
||||
| setToken(value, isLocalStorage) | Set the user's `jwtToken` in the `sessionStorage`. If `true` is passed as the 2nd parameter it sets the value in the `localStorage` |
|
||||
| setUserInfo(value, isLocalStorage) | Set the user's info in the `sessionStorage`. If `true` is passed as the 2nd parameter it sets the value in the `localStorage` |
|
||||
|
||||
|
||||
```js
|
||||
import auth from 'utils/auth';
|
||||
|
||||
// ...
|
||||
//
|
||||
auth.setToken('12345', true); // This will set 1234 in the browser's localStorage associated with the key: jwtToken
|
||||
```
|
||||
|
||||
## Colors
|
||||
|
||||
This function allows to darken a color.
|
||||
|
||||
### Usage
|
||||
|
||||
```js
|
||||
import { darken } from 'utils/colors';
|
||||
|
||||
const linkColor = darken('#f5f5f5', 1.5); // Will darken #F5F5F5 by 1.5% which gives #f2f2f2.
|
||||
```
|
||||
|
||||
## Get URL Query Parameters
|
||||
|
||||
The helpers allows to retrieve the query parameters in the URL.
|
||||
|
||||
### Example
|
||||
|
||||
```js
|
||||
import getQueryParameters from 'utils/getQueryParameters';
|
||||
|
||||
const URL = '/create?source=users-permissions';
|
||||
const source = getQueryParameters(URL, 'source');
|
||||
|
||||
console.log(source); // users-permissions
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Request helper
|
||||
|
||||
A request helper is available to handle all requests inside a plugin.
|
||||
@ -368,7 +425,6 @@ function* defaultSaga() {
|
||||
export default defaultSaga;
|
||||
```
|
||||
|
||||
***
|
||||
***
|
||||
|
||||
### Example with server autoReload watcher
|
||||
|
Loading…
x
Reference in New Issue
Block a user