Skip to content

Instantly share code, notes, and snippets.

@junchoon14
Forked from srph/oauth.js
Created November 8, 2019 14:22
Show Gist options
  • Save junchoon14/63f774a62b136a9aca37b04177ef92dc to your computer and use it in GitHub Desktop.
Save junchoon14/63f774a62b136a9aca37b04177ef92dc to your computer and use it in GitHub Desktop.

Revisions

  1. @srph srph created this gist Feb 21, 2016.
    16 changes: 16 additions & 0 deletions oauth.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    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}`;
    }

    return config;
    }, function(err) {
    return Promise.reject(err);
    });