How to use devour-client - 4 common examples

To help you get started, we’ve selected a few devour-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github daptin / daptin / gomsweb / src / plugins / jsonapi.js View on Github external
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();
github daptin / daptin / gocms / src / main.js View on Github external
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) {
github daptin / daptin / daptinweb / src / plugins / jsonapi.js View on Github external
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
      });
github hummingbird-me / kitsu-mobile / src / config / api.js View on Github external
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: '',

devour-client

A lightweight, framework agnostic, flexible JSON API client

ISC
Latest version published 2 years ago

Package Health Score

61 / 100
Full package analysis

Popular devour-client functions