fix: server api util
This commit is contained in:
parent
0d7eb8f132
commit
edf03a04ee
@ -25,13 +25,13 @@ export interface PagedResult<T> {
|
||||
// 获取.env文件中的变量
|
||||
|
||||
|
||||
export const API_ENDPOINT = () => Constants.expoConfig?.extra?.API_ENDPOINT || "http://192.168.31.115:18080/api";
|
||||
export const API_ENDPOINT = Constants.expoConfig?.extra?.API_ENDPOINT || "http://192.168.31.115:18080/api";
|
||||
|
||||
// 更新 access_token 的逻辑 - 用于React组件中
|
||||
export const useAuthToken = async<T>(message: string | null) => {
|
||||
try {
|
||||
const { login } = useAuth();
|
||||
const response = await fetch(`${API_ENDPOINT()}/v1/iam/access-token-refresh`);
|
||||
const response = await fetch(`${API_ENDPOINT}/v1/iam/access-token-refresh`);
|
||||
const apiResponse: ApiResponse<T> = await response.json();
|
||||
|
||||
// 如果接口报错,页面弹出来错误信息
|
||||
@ -73,7 +73,7 @@ export const refreshAuthToken = async<T>(message: string | null): Promise<User>
|
||||
// 退出刷新会重新填充数据
|
||||
let response;
|
||||
|
||||
response = await fetch(`${API_ENDPOINT()}/v1/iam/access-token-refresh`, {
|
||||
response = await fetch(`${API_ENDPOINT}/v1/iam/access-token-refresh`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
"refresh_token": cookie,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user