SHARE
TWEET

Untitled

a guest Mar 19th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import _ from 'lodash'
  2. import createGuest from '@/graphql/mutations/createGuest'
  3. import EventsService from './EventsService'
  4.  
  5. export default vm => ({
  6.   identityToken: vm.identityToken,
  7.  
  8.   events() {
  9.     return new EventsService(vm)
  10.   },
  11.  
  12.   perform() {
  13.     if (_.isNil(vm.identityToken)) {
  14.       this._connectGuest()
  15.     }
  16.     console.log('identityToken : ' + vm.identityToken)
  17.   },
  18.  
  19.   async _connectGuest() {
  20.     try {
  21.       console.log('connect anonymous ...')
  22.       const response = await createGuest(vm)
  23.       console.log(response)
  24.       localStorage.setItem('identityToken', response.token)
  25.     } catch (error) {
  26.       this.events().crash('We were unable to create an anonymous user')
  27.     }
  28.   }
  29. })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top