parent
729a28b9ef
commit
81c352d376
@ -1,18 +1,23 @@
|
||||
import clientHttp from '@/request/client';
|
||||
import { request, verifyResponse } from '@/utils';
|
||||
import serverHttp from '@/utils/request/server';
|
||||
|
||||
/**
|
||||
* @description 获取支持的手机号国家码
|
||||
*/
|
||||
export const apiGetSupportedCountryCode = async () => {
|
||||
const res = await request('/luoo-user/user/supportedCountryCode');
|
||||
return verifyResponse(res);
|
||||
};
|
||||
// export const apiGetSupportedCountryCode = async () => {
|
||||
// const res = await request('/luoo-user/user/supportedCountryCode');
|
||||
// return verifyResponse(res);
|
||||
// };
|
||||
|
||||
/**
|
||||
* @description 获取贡献者
|
||||
*/
|
||||
export const apiThanks = async () => {
|
||||
const res: FetchResponse<UserInfo[]> = await clientHttp.get('/luoo-user/my/thanks');
|
||||
return verifyResponse(res);
|
||||
export const apiThanks = async (): Promise<FetchResponse<UserInfo[]>> => {
|
||||
const request = new Request('http://localhost', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
requestUrl: '/luoo-user/my/thanks',
|
||||
},
|
||||
});
|
||||
const res = await serverHttp.get(request);
|
||||
return res;
|
||||
};
|
||||
|
@ -1,17 +0,0 @@
|
||||
// server端
|
||||
import { cookies } from 'next/headers';
|
||||
|
||||
export const nextFetchGet = async (api: string) => {
|
||||
const nextCookies = cookies();
|
||||
const token = nextCookies.get('token') || '';
|
||||
const role = nextCookies.get('role');
|
||||
const roleId = nextCookies.get('roleId');
|
||||
const url = `${process.env.BASE_FETCH_URL}/queyueapi/be${api}`;
|
||||
const res = await fetch(url, {
|
||||
headers: token ? { Authorization: 'Bearer ' + token } : {},
|
||||
});
|
||||
if (!res.ok) {
|
||||
throw new Error('Failed to fetch data');
|
||||
}
|
||||
return res.json();
|
||||
};
|
@ -1,5 +1,11 @@
|
||||
import { getAuthorization, getStringParams, handleResponse, hostMap, createFormBody } from '@/request/client/utils';
|
||||
import { IAuthType, IResponse } from '@/request/type';
|
||||
import {
|
||||
getAuthorization,
|
||||
getStringParams,
|
||||
handleResponse,
|
||||
hostMap,
|
||||
createFormBody,
|
||||
} from '@/utils/request/client/utils';
|
||||
import { IAuthType, IResponse } from '@/utils/request/type';
|
||||
|
||||
export const post = async <T>(url: string, data: any, revalidate = 20): Promise<IResponse<T>> => {
|
||||
const token = await getAuthorization();
|
Loading…
Reference in new issue