本文整理汇总了TypeScript中simple-query-string.stringify函数的典型用法代码示例。如果您正苦于以下问题:TypeScript stringify函数的具体用法?TypeScript stringify怎么用?TypeScript stringify使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stringify函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: buildOptions
function buildOptions(config: HttpClientConfig): Request {
let url = config.url;
if (config.params) {
url = `${url}?${stringify(config.params)}`;
}
return new Request(url, {
method: config.method,
body: JSON.stringify(config.body),
headers: {
'X-API-Key': API_KEY,
'Content-Type': 'application/json'
},
credentials: 'include'
});
}
示例2: getAccessTokenFromRefreshToken
export function getAccessTokenFromRefreshToken(refreshToken) {
return fetch(TOKEN_URL, {
method: 'POST',
body: stringify({
grant_type: 'refresh_token',
refresh_token: refreshToken.value,
client_id: oauthClientId(),
client_secret: oauthClientSecret()
}),
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
})
.then((response) => response.ok ? response.json() : Promise.reject(response))
.then(handleAccessToken);
}
示例3: getAccessTokenFromCode
export function getAccessTokenFromCode(code: number): Promise<Tokens> {
return Promise.resolve(
fetch(TOKEN_URL, {
method: 'POST',
body: stringify({
grant_type: 'authorization_code',
code,
client_id: oauthClientId(),
client_secret: oauthClientSecret()
}),
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
})
.then((response) => (response.ok ? response.json() : Promise.reject(response)))
.then(handleAccessToken)
);
}
示例4: getAccessTokenFromRefreshToken
export function getAccessTokenFromRefreshToken(refreshToken: Token): Promise<Tokens> {
// https://github.com/zloirock/core-js/issues/178#issuecomment-192081350
return Promise.resolve(
fetch(TOKEN_URL, {
method: 'POST',
body: stringify({
grant_type: 'refresh_token',
refresh_token: refreshToken.value,
client_id: oauthClientId(),
client_secret: oauthClientSecret()
}),
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
})
.then((response) => (response.ok ? response.json() : Promise.reject(response)))
.then(handleAccessToken)
);
}