How to use tg-resources - 6 common examples

To help you get started, we’ve selected a few tg-resources 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 thorgate / django-project-template / {{cookiecutter.repo_name}} / {{cookiecutter.repo_name}} / app-spa / src / resources / GenericResource.js View on Github external
import SingleObjectResource, {setConfig} from 'tg-resources';

import logger from '../logger';
import CurrentUserActions from '../actions/CurrentUserActions';

import {getExtraHeaders, getCookies} from './headers';


// Configure tg-resources
logger.debug('Configuring tg-resources');
setConfig('API_BASE', DJ_CONST.API_BASE);
setConfig('onSourceError', CurrentUserActions.pageFault);
setConfig('getExtraHeaders', getExtraHeaders);
setConfig('getCookies', getCookies);


export default SingleObjectResource;
export {InvalidResponseCode, ValidatonError} from 'tg-resources';
github thorgate / django-project-template / {{cookiecutter.repo_name}} / {{cookiecutter.repo_name}} / app-spa / src / resources / GenericResource.js View on Github external
import SingleObjectResource, {setConfig} from 'tg-resources';

import logger from '../logger';
import CurrentUserActions from '../actions/CurrentUserActions';

import {getExtraHeaders, getCookies} from './headers';


// Configure tg-resources
logger.debug('Configuring tg-resources');
setConfig('API_BASE', DJ_CONST.API_BASE);
setConfig('onSourceError', CurrentUserActions.pageFault);
setConfig('getExtraHeaders', getExtraHeaders);
setConfig('getCookies', getCookies);


export default SingleObjectResource;
export {InvalidResponseCode, ValidatonError} from 'tg-resources';
github thorgate / django-project-template / {{cookiecutter.repo_name}} / {{cookiecutter.repo_name}} / app-spa / src / resources / GenericResource.js View on Github external
import SingleObjectResource, {setConfig} from 'tg-resources';

import logger from '../logger';
import CurrentUserActions from '../actions/CurrentUserActions';

import {getExtraHeaders, getCookies} from './headers';


// Configure tg-resources
logger.debug('Configuring tg-resources');
setConfig('API_BASE', DJ_CONST.API_BASE);
setConfig('onSourceError', CurrentUserActions.pageFault);
setConfig('getExtraHeaders', getExtraHeaders);
setConfig('getCookies', getCookies);


export default SingleObjectResource;
export {InvalidResponseCode, ValidatonError} from 'tg-resources';
github thorgate / django-project-template / {{cookiecutter.repo_name}} / {{cookiecutter.repo_name}} / app-spa / src / resources / GenericResource.js View on Github external
import SingleObjectResource, {setConfig} from 'tg-resources';

import logger from '../logger';
import CurrentUserActions from '../actions/CurrentUserActions';

import {getExtraHeaders, getCookies} from './headers';


// Configure tg-resources
logger.debug('Configuring tg-resources');
setConfig('API_BASE', DJ_CONST.API_BASE);
setConfig('onSourceError', CurrentUserActions.pageFault);
setConfig('getExtraHeaders', getExtraHeaders);
setConfig('getCookies', getCookies);


export default SingleObjectResource;
export {InvalidResponseCode, ValidatonError} from 'tg-resources';
github thorgate / django-project-template / {{cookiecutter.repo_name}} / {{cookiecutter.repo_name}} / app / src / utils / api.js View on Github external
import Router, {Resource} from 'tg-resources';
import {getCookie} from 'utils/cookie';

const resources = Object.entries(DJ_CONST.API || {})
    .filter(item => item[0] !== 'apiRoot')
    .reduce((result, [key, url]) => {
        result[key] = new Resource(url); // eslint-disable-line no-param-reassign
        return result;
    }, {});


const api = new Router(
    resources,
    {
        apiRoot: DJ_CONST.API_BASE,
        headers: () => ({
            Accept: 'application/json',
            'X-CSRFToken': getCookie('csrftoken'),
        }),
        withCredentials: true,
    },
);

export default api;
github thorgate / django-project-template / {{cookiecutter.repo_name}} / {{cookiecutter.repo_name}} / app / src / utils / api.js View on Github external
.reduce((result, [key, url]) => {
        result[key] = new Resource(url); // eslint-disable-line no-param-reassign
        return result;
    }, {});

tg-resources

MIT
Latest version published 1 month ago

Package Health Score

73 / 100
Full package analysis

Similar packages