本文整理汇总了TypeScript中js-cookie.get函数的典型用法代码示例。如果您正苦于以下问题:TypeScript get函数的具体用法?TypeScript get怎么用?TypeScript get使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
export let getToken = function (): TokenStateSchema | null {
let user = Cookies.get('user');
let token = Cookies.get('token');
if (user !== undefined && token !== undefined) {
return {token: token, user: user};
}
return null;
};
示例2: loadSessionState
export function loadSessionState() {
return {
type: LOAD_SESSION_STATE,
payload: {
gitHubAuthToken: cookies.get("gitHubAuthToken"),
gitHubAuthState: cookies.get("gitHubAuthState"),
},
};
}
示例3: setVisitorInfo
setVisitorInfo() {
const visitorId = this._config.visitorId
|| Cookies.get(VISITOR_COOKIE_KEY)
|| uuid.v1();
const sessionId = this._config.sessionId
|| Cookies.get(SESSION_COOKIE_KEY)
|| uuid.v1();
this.setVisitor(visitorId, sessionId);
}
示例4: applyTheme
/**
* Applies the theme to the website
*/
public applyTheme() {
if (Cookie.get('theme') == 'dark') {
this.setDarkTheme();
} else {
this.setLightTheme();
}
}
示例5: normalizeBaseURL
export const createAJAXSettings = (
serverConfig: ServerConfig,
uri = "/",
opts: Partial<AjaxRequest> = {}
): AjaxRequest => {
const baseURL = normalizeBaseURL(serverConfig.endpoint || serverConfig.url);
const url = `${baseURL}${uri}`;
// Use the server config provided token if available before trying cookies
const xsrfToken = serverConfig.xsrfToken || Cookies.get("_xsrf");
const headers = {
"X-XSRFToken": xsrfToken,
Authorization: `token ${serverConfig.token ? serverConfig.token : ""}`
};
// Merge in our typical settings for responseType, allow setting additional
// options like the method
const settings = {
url,
responseType: "json",
createXHR: () => new XMLHttpRequest(),
...serverConfig,
...opts,
// Make sure we merge in the auth headers with user given headers
headers: { ...headers, ...opts.headers }
};
delete settings.endpoint;
return settings;
};
示例6: fetchGitHubRepos
export function fetchGitHubRepos(org, page = 1, username) {
const token = cookies.get("gitHubAuthToken");
const urlPath = username ? `users/${username}/repos` : `orgs/${org}/repos`;
return dispatch => {
if (page === 1) {
dispatch(setGitHubReposLoadingFlag(true));
}
fetch(`https://api.github.com/${urlPath}?access_token=${token}&per_page=100&page=${page}`).then(response => {
const links = parseLinkHeader(response.headers.get("Link"));
// When we get the first page, clear everything out
if (page === 1) { dispatch(resetGitHubRepos()); }
if (links && links.next && links.next.page) {
dispatch(fetchGitHubRepos(org, links.next.page, username));
} else {
dispatch(setGitHubReposLoadingFlag(false));
}
response.json().then(data => dispatch(populateGitHubRepos(data)));
});
};
}
示例7: score_update
score_update(add_to_score:number) {
this.max_score = parseInt(Cookies.get('max_score'), 10) || 0;
this.score += add_to_score;
if (this.score > this.max_score) {
Cookies.set('max_score', this.max_score);
}
}
示例8: addToBasket
public static addToBasket(item) {
const basket = JSON.parse(Cookies.get('basket'));
const {id} = basket;
const uri = `${ITEM_URI}/${id}/order_items`;
const data = {size: item.size, shoeModelId: item.id};
APIUtils.post(uri, data)
.then(BasketServerActions.receiveBasketItemPush);
}
示例9: setGitHubAuthState
export function setGitHubAuthState() {
let payload = cookies.get("gitHubAuthState") || uuid();
setCookie("gitHubAuthState", payload);
return {
type: SET_GITHUB_AUTH_STATE,
payload
};
}
示例10: constructor
constructor(x_size, y_size) {
this.array = [];
this.x_size = x_size;
this.y_size = y_size;
this.score = 0;
this.max_score = parseInt(Cookies.get('max_score'), 10) || 0;
for (let i = 0; i < this.x_size * this.y_size; i++) {
this.array[i] = null;
}
}