Skip to content

Instantly share code, notes, and snippets.

View ZakKa89's full-sized avatar
👨‍💻
zakka.dev

Zakaria Abu Sarah ザカリヤ ZakKa89

👨‍💻
zakka.dev
View GitHub Profile
@Akryum
Akryum / PostUpvoter.vue
Created September 22, 2016 08:21
Apollo mutation example in a Vue component
<script>
import gql from 'graphql-tag';
// GraphQL Mutation with one parameter
const upvoteMutation = gql`
mutation upvotePost($postId: Int!) {
upvotePost(postId: $postId) {
id
votes
}
@srph
srph / expired.js
Last active April 1, 2021 07:08
axios + react-router: handling invalid tokens through axios interceptors
import axios from 'axios';
import cookie from 'cookie-machine';
import {hashHistory} from 'react-router';
axios.interceptors.response.use(null, function(err) {
if ( err.status === 401 ) {
cookie.remove('my-token-key');
hashHistory.push('/login');
}
@srph
srph / oauth.js
Created February 21, 2016 13:50
axios: interceptor which includes your oauth token in every request as an Authorization header
import axios from 'axios';
// You can use any cookie library or whatever
// library to access your client storage.
import cookie from 'cookie-machine';
axios.interceptors.request.use(function(config) {
const token = cookie.get(__TOKEN_KEY__);
if ( token != null ) {
config.headers.Authorization = `Bearer ${token}`;
@gokulkrishh
gokulkrishh / media-query.css
Last active May 8, 2024 06:59
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
/* CSS */