Skip to content

Instantly share code, notes, and snippets.

View brybrophy's full-sized avatar

Bryan Brophy brybrophy

  • Outreach
  • Tacoma, WA, USA
View GitHub Profile
import baseApi from './api';
import { displayUserFeedback } from './utils';
export async function handleClickGetAllUsers() {
try {
return await baseApi.users.getAll();
} catch () {
displayUserFeedback('There was an error retrieving the users.');
}
}
import ApiCore from 'axios-core-api';
import axiosConfig from './axiosConfig.js';
import UsersApi from './UsersApi';
class BaseApi {
constructor(apiCore, basePath) {
this._apiCore = apiCore;
this._basePath = basePath;
this.users = new UsersApi(this._apiCore, this._basePath);
export default class UsersApi {
constructor(apiCore, basePath) {
this._apiCore = apiCore;
this._basePath = `${basePath}/users`;
}
getAll() {
return this._apiCore.get(this._basePath);
}
import ApiCore from 'axios-core-api';
import axiosConfig from './axiosConfig.js';
class BaseApi {
constructor(apiCore, basePath) {
this._apiCore = apiCore;
this._basePath = basePath;
}
}
import ApiCore from 'axios-core-api';
import axiosConfig from './axiosConfig.js';
class BaseApi {
constructor(apiCore) {
this._apiCore = apiCore;
}
}
const apiCore = new ApiCore(axiosConfig);
export default {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
timeout: 15000
};
import ApiCore from 'axios-core-api';
class BaseApi {
constructor(apiCore) {
this._apiCore = apiCore;
}
}
const apiCore = new ApiCore();
const baseApi = new BaseApi(apiCore);
import axios from 'axios';
import { displayUserFeedback } from './utils';
const axiosConfig = {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
timeout: 15000
};
import axios from 'axios';
import { displayUserFeedback } from './utils';
export function handleClickGetAllUsers() {
axios.get('https://www.example.org/api/users', {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
timeout: 15000
@brybrophy
brybrophy / slideMixin.scss
Last active June 20, 2017 00:18
A SASS mixin to slide an element in any cardinal direction, at any speed, for any distance.
// example 1: @include slide(up, 125ms, 100%);
// example 2: No distance required for "off" @include slide(off, 125ms);
// example 3:
// div {
// @include slide(up, 250ms, 100%);
//
// &.is-visible {
// @include slide(off, 125ms);
// }