Support saving existing files

This commit is contained in:
Dane Everitt 2019-05-27 15:30:49 -07:00
parent a8f523e2aa
commit bfdc1f766b
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
6 changed files with 95 additions and 2 deletions

View file

@ -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;
}