@wepin/storage-js
v0.0.35
Published
Wepin SDK storage for Web
Readme
@wepin/storage-js
Wepin Storage Library from Web. This package is only available in the web environment.
⏩ Install
npm install @wepin/storage-jsor
yarn add @wepin/storage-js⏩ Import SDK
WepinStorage from '@wepin/storage-js'⏩ Methods
getLocalStorage
WepinStorage.getLocalStorage(appId, name)Returns the value of the specified local storage item.
Parameters
appId<string>name<string>
Example
WepinStorage.getLocalStorage('APP_ID', 'KEY')getAllLocalStorage
WepinStorage.getAllLocalStorage(appId)Returns all local storage data.
Parameters
appId<string>
Example
WepinStorage.getAllLocalStorage('APP_ID')setLocalStorage
WepinStorage.setLocalStorage(appId, name, value)Sets the value of the specified local storage item.
Parameters
appId<string>name<string>value<any>
Example
WepinStorage.setLocalStorage('APP_ID', 'KEY', 'data')setAllLocalStorage
WepinStorage.setAllLocalStorage(appId, values)Sets all local storage data.
Parameters
appId<string>values<any>
Example
WepinStorage.setAllLocalStorage('APP_ID', 'data')clearLocalStorage
WepinStorage.clearLocalStorage(appId, name)Clears the value of the specified local storage item.
Parameters
appId<string>name<string>
Example
WepinStorage.clearLocalStorage('APP_ID', 'KEY')clearAllLocalStorage
WepinStorage.clearAllLocalStorage(appId)Clears all local storage data.
Parameters
appId<string>
Example
WepinStorage.clearAllLocalStorage('APP_ID')setLoginUserLocalStorage
WepinStorage.setLoginUserLocalStorage(
appId: string,
request: {
provider: string
token: { idToken: string; refreshToken: string }
},
response: any,
)Sets the user information of the local storage.
Parameters
appId<string>request<string> - response of@wepin/loign-jsmethodsresponse<string> - response of wepin login api
Example
import {WepinFetch} from '@wepin/fetch-js'
import {WepinLogin} from '@wepin/login-js'
const wepinLogin = new WepinLogin({
appId: 'APP_ID',
appKey: 'APP_KEY',
})
const wepinFetch = new WepinFetch({
appId: 'APP_ID',
appKey: 'APP_KEY',
domain: 'APP_DOMAIN',
sdk: {version: 'SDK_VERSION', type: "SDK_TYPE"}
})
const req = await wepinLogin.loginWithIdToken({token, sign})
const res = await wepinFetch.wepinApi.user.login({
idToken: req.token.idToken,
})
WepinStorage.setLoginUserLocalStorage('APP_ID', req, res)