9-2:トークン、fetch、debugger
[サーバ]トークンベースの認証VSサーバベースの認証
Access Token & Refresh Token
Fetch関数サンプルコード
export class AdminUserService {
static createAdminUser = (params) => {
let apiPath = `${API_BASE_URL}/admin-users`;
return fetch(apiPath, {
method: "POST",
body: JSON.stringify(params),
headers: HttpUtil.getHeader(),
})
.then(HttpUtil.handleHttpStatus)
.catch(HttpUtil.handleHttpStatusError)
.then((res) => res.json());
};
post方式で伝達するときのコード.body
必要なデータは対象として整理し、JSON.stringify()
関数でstringに変換する.("{"key": "value", "key2": "value2", ...}.catch()
文はfetch()
のみならず.then()
でもエラーが実行される.debugger
使い方console.log
と似ていますが、いちいち撮影する必要はなく、データを一度に表示します.Reference
この問題について(9-2:トークン、fetch、debugger), 我々は、より多くの情報をここで見つけました https://velog.io/@dulcis-hortus/9-2テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol