本文整理匯總了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;
}
}