update apix.ts and siteurl.ts
This commit is contained in:
parent
3c8c450dc2
commit
100b44f024
|
|
@ -14,6 +14,7 @@ type apixType = {
|
||||||
label: string | ((item: any) => string);
|
label: string | ((item: any) => string);
|
||||||
};
|
};
|
||||||
header?: "normal" | "form";
|
header?: "normal" | "form";
|
||||||
|
options?: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const apix = async ({
|
export const apix = async ({
|
||||||
|
|
@ -26,6 +27,7 @@ export const apix = async ({
|
||||||
type = "usual",
|
type = "usual",
|
||||||
header = "normal",
|
header = "normal",
|
||||||
keys,
|
keys,
|
||||||
|
options,
|
||||||
}: apixType) => {
|
}: apixType) => {
|
||||||
const root_url = `${
|
const root_url = `${
|
||||||
port === "portal"
|
port === "portal"
|
||||||
|
|
@ -56,13 +58,16 @@ export const apix = async ({
|
||||||
try {
|
try {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case "get":
|
case "get":
|
||||||
result = await api.get(root_url);
|
result = await api.get(root_url, {
|
||||||
|
...options,
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "post":
|
case "post":
|
||||||
result = await api.post(root_url, requestData, {
|
result = await api.post(root_url, requestData, {
|
||||||
headers:
|
headers:
|
||||||
type === "form" ? { "Content-Type": "multipart/form-data" } : {},
|
type === "form" ? { "Content-Type": "multipart/form-data" } : {},
|
||||||
|
...options,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -70,6 +75,7 @@ export const apix = async ({
|
||||||
result = await api.put(root_url, requestData, {
|
result = await api.put(root_url, requestData, {
|
||||||
headers:
|
headers:
|
||||||
type === "form" ? { "Content-Type": "multipart/form-data" } : {},
|
type === "form" ? { "Content-Type": "multipart/form-data" } : {},
|
||||||
|
...options,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,18 @@
|
||||||
import dotenv from "dotenv";
|
import dotenv from "dotenv";
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
export const siteurl = (param: string) => {
|
export const siteurl = (
|
||||||
|
param: string,
|
||||||
|
port?: "portal" | "recruitment" | "mpp"
|
||||||
|
) => {
|
||||||
if (param && param.startsWith("http")) return param;
|
if (param && param.startsWith("http")) return param;
|
||||||
return `${process.env.NEXT_PUBLIC_BASE_URL + param}`;
|
const root_url = `${
|
||||||
|
port === "portal"
|
||||||
|
? process.env.NEXT_PUBLIC_API_PORTAL
|
||||||
|
: port === "recruitment"
|
||||||
|
? process.env.NEXT_PUBLIC_API_RECRUITMENT
|
||||||
|
: port === "mpp"
|
||||||
|
? process.env.NEXT_PUBLIC_API_MPP
|
||||||
|
: process.env.NEXT_PUBLIC_BASE_URL
|
||||||
|
}${param}`;
|
||||||
|
return `${root_url}`;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue