Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import JsonApi from "devour-client"
import {Notification} from "element-ui"
import appConfig from "../plugins/appconfig"
import {getToken, unsetToken} from '../utils/auth'
import {mapState} from 'vuex';
const jsonapi = new JsonApi({
apiUrl: appConfig.apiRoot + '/api',
pluralize: false
});
jsonapi.replaceMiddleware('errors', {
name: 'nothing-to-see-here',
error: function (payload) {
// console.log("errors", payload);
if (payload.status === 401) {
Notification.error({
"title": "Failed",
"message": payload.data
});
unsetToken();
Vue.component("detailed-table-row", DetailedRow);
Vue.component("vuetable-pagination", VuetablePagination);
// Vue.component("vuetable-pagination-dropdown", Vuetable.VueTablePaginationDropDown);
// Vue.component("vuetable-pagination-info", Vuetable.VueTablePaginationInfo);
window.apiRoot = window.location.protocol + "//" + window.location.host;
if (window.location.hostname == "site.goms") {
window.apiRoot = window.location.protocol + "//" + "api.goms:6336";
}
window.jsonApi = new JsonApi({
apiUrl: window.apiRoot + '/api',
pluralize: false
});
// window.jsonApiClient = new JsonapiClient(window.apiRoot, {
// header: {
// Authorization: "Bearer " + window.localStorage.getItem("id_token")
// }
// });
//
// Add a response interceptor
axios.interceptors.response.use(function (response) {
// Do something with response data
return response;
}, function (error) {
import JsonApi from "devour-client"
import {Notification} from "element-ui"
import appConfig from "../plugins/appconfig"
import {getToken, unsetToken} from '../utils/auth'
import {mapState} from 'vuex';
const jsonapi = new JsonApi({
apiUrl: appConfig.apiRoot + '/api',
pluralize: false,
logger: false
});
jsonapi.replaceMiddleware('errors', {
name: 'nothing-to-see-here',
error: function (response) {
console.log("errors", response);
response = response.response.data.errors[0];
if (response.status === 401) {
Notification.error({
"title": "Failed",
"message": response.data
});
import OAuth2 from 'client-oauth2';
import JsonApi from 'devour-client';
import { kitsuConfig } from './env';
import { errorMiddleware, kitsuRequestMiddleware, titleMiddleware } from './middlewares';
export const auth = new OAuth2({
clientId: kitsuConfig.authConfig.CLIENT_ID,
clientSecret: kitsuConfig.authConfig.CLIENT_SECRET,
accessTokenUri: `${kitsuConfig.baseUrl}/oauth/token`,
});
export const Kitsu = new JsonApi({
apiUrl: `${kitsuConfig.baseUrl}/edge`,
logger: false,
pluralize: false,
});
Kitsu.headers['User-Agent'] = `KitsuMobile/${kitsuConfig.version}`;
Kitsu.replaceMiddleware('errors', errorMiddleware);
Kitsu.replaceMiddleware('axios-request', kitsuRequestMiddleware);
Kitsu.insertMiddlewareAfter('response', titleMiddleware);
Kitsu.define(
'users',
{
name: '',
email: '',
avatar: '',