mirror of
https://github.com/MedzikUser/HomeDisk.git
synced 2024-08-14 21:46:53 +00:00
34 lines
726 B
TypeScript
34 lines
726 B
TypeScript
import axios from './axios'
|
|
|
|
export default async function createDir(path: string, token: string): Promise<any> {
|
|
const request = axios.post("/fs/createdir", {
|
|
path
|
|
}, {
|
|
headers: {
|
|
Authorization: `Bearer ${token}`,
|
|
}
|
|
})
|
|
|
|
const response = request
|
|
.then(response => {
|
|
const { data } = response
|
|
return data
|
|
})
|
|
.catch(err => {
|
|
if (err.response?.data?.error_message) {
|
|
const error = err.response.data.error_message
|
|
|
|
if (error.toString() == "[object Object]") {
|
|
Object.keys(error).forEach(key => {
|
|
throw new Error(key)
|
|
})
|
|
}
|
|
|
|
throw new Error(error)
|
|
}
|
|
|
|
throw new Error(err)
|
|
})
|
|
|
|
return response
|
|
}
|