refactor: always add slash in front
This commit is contained in:
parent
182ddc2d92
commit
d826188915
2 changed files with 331 additions and 8 deletions
|
|
@ -239,7 +239,7 @@ export function manageAttachment(api: AxiosInstance, base: string) {
|
|||
return {
|
||||
listAttachment: async (opts: { parentId: string }) => {
|
||||
const res = await api.get<string[]>(
|
||||
`${base}/${opts.parentId}/attachment`,
|
||||
`/${base}/${opts.parentId}/attachment`,
|
||||
);
|
||||
if (res.status >= 400) return false;
|
||||
return res.data;
|
||||
|
|
@ -249,7 +249,7 @@ export function manageAttachment(api: AxiosInstance, base: string) {
|
|||
name: string;
|
||||
download?: boolean;
|
||||
}) => {
|
||||
const url = `${base}/${opts.parentId}/attachment/${opts.name}`;
|
||||
const url = `/${base}/${opts.parentId}/attachment/${opts.name}`;
|
||||
const res = await api.get<string>(url);
|
||||
if (opts.download) {
|
||||
fetch(res.data)
|
||||
|
|
@ -270,7 +270,7 @@ export function manageAttachment(api: AxiosInstance, base: string) {
|
|||
file: File;
|
||||
}) => {
|
||||
const res = await api.put(
|
||||
`${base}/${opts.parentId}/attachment/${opts.name}`,
|
||||
`/${base}/${opts.parentId}/attachment/${opts.name}`,
|
||||
opts.file,
|
||||
{
|
||||
headers: { 'Content-Type': opts.file.type },
|
||||
|
|
@ -282,7 +282,7 @@ export function manageAttachment(api: AxiosInstance, base: string) {
|
|||
},
|
||||
delAttachment: async (opts: { parentId: string; name: string }) => {
|
||||
const res = await api.delete(
|
||||
`${base}/${opts.parentId}/attachment/${opts.name}`,
|
||||
`/${base}/${opts.parentId}/attachment/${opts.name}`,
|
||||
);
|
||||
if (res.status < 400) return true;
|
||||
return false;
|
||||
|
|
@ -294,7 +294,7 @@ export function manageFile<T extends string>(api: AxiosInstance, base: string) {
|
|||
return {
|
||||
listFile: async (opts: { group: T; parentId: string }) => {
|
||||
const res = await api.get<string[]>(
|
||||
`${base}/${opts.parentId}/file-${opts.group}`,
|
||||
`/${base}/${opts.parentId}/file-${opts.group}`,
|
||||
);
|
||||
if (res.status >= 400) return false;
|
||||
return res.data;
|
||||
|
|
@ -305,7 +305,7 @@ export function manageFile<T extends string>(api: AxiosInstance, base: string) {
|
|||
fileId: string;
|
||||
download?: boolean;
|
||||
}) => {
|
||||
const url = `${base}/${opts.parentId}/file-${opts.group}/${opts.fileId}`;
|
||||
const url = `/${base}/${opts.parentId}/file-${opts.group}/${opts.fileId}`;
|
||||
const res = await api.get<string>(url);
|
||||
if (opts.download) {
|
||||
fetch(res.data)
|
||||
|
|
@ -327,7 +327,7 @@ export function manageFile<T extends string>(api: AxiosInstance, base: string) {
|
|||
file: File;
|
||||
}) => {
|
||||
const res = await api.put(
|
||||
`${base}/${opts.parentId}/file-${opts.group}/${opts.fileId}`,
|
||||
`/${base}/${opts.parentId}/file-${opts.group}/${opts.fileId}`,
|
||||
opts.file,
|
||||
{
|
||||
headers: { 'Content-Type': opts.file.type },
|
||||
|
|
@ -339,7 +339,7 @@ export function manageFile<T extends string>(api: AxiosInstance, base: string) {
|
|||
},
|
||||
delFile: async (opts: { group: T; parentId: string; fileId: string }) => {
|
||||
const res = await api.delete(
|
||||
`${base}/${opts.parentId}/file-${opts.group}/${opts.fileId}`,
|
||||
`/${base}/${opts.parentId}/file-${opts.group}/${opts.fileId}`,
|
||||
);
|
||||
if (res.status < 400) return true;
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue