jwt-network
v1.0.5
Published
base on fetch,support cors,work with jwt,compatible with almost all browsers
Downloads
4
Readme
1、install from npm
npm i jwt-network
2、initialization
import Jwt from 'jwt-network';
const {JwtNetWork, JwtToken} = Jwt;
const token = new JwtToken();
const props = {
contextUrl: 'https://127.0.0.1:8080/',
jwtToken: token
};
const network = new JwtNetWork(props);
3、get token from server
const auth = () => network.fetchGet("/auth").then(rs => {
token.setJwtToken(rs);
});
4、It can be used anywhere in your App
5、clearJwtToken
const logoutCallback = () => token.clearJwtToken();