Support saving existing files
This commit is contained in:
parent
a8f523e2aa
commit
bfdc1f766b
6 changed files with 95 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
|||
import axios, {AxiosInstance} from 'axios';
|
||||
import axios, {AxiosError, AxiosInstance} from 'axios';
|
||||
import {ServerApplicationCredentials} from "@/store/types";
|
||||
|
||||
// This token is set in the bootstrap.js file at the beginning of the request
|
||||
|
@ -38,3 +38,18 @@ export function withCredentials(server: string, credentials: ServerApplicationCr
|
|||
|
||||
return http;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an error into a human readable response. Mostly just a generic helper to
|
||||
* make sure we display the message from the server back to the user if we can.
|
||||
*/
|
||||
export function httpErrorToHuman(error: any): string {
|
||||
if (error.response && error.response.data) {
|
||||
const { data } = error.response;
|
||||
if (data.errors && data.errors[0] && data.errors[0].detail) {
|
||||
return data.errors[0].detail;
|
||||
}
|
||||
}
|
||||
|
||||
return error.message;
|
||||
}
|
||||
|
|
Reference in a new issue