Skip to main content
JavaScript
// Basic login
Smile.customer.login({
  customerToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
}).then(() => {
  // Customer logged in successfully
});

// Login with preloading
Smile.customer.login({
  customerToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
  preload: ['rewardFulfillments']
}).then(() => {
  // Customer logged in and preloaded resources successfully
});

This async method logs in a customer using the provided token while also preloading resources into the cache.

Parameters

customerToken
string
required
A customer token identifying the individual who is being logged in.
preload
array
An array with one or multiple of the available resource keys.

Returns

This method returns a Promise that:
  • On success, resolves to void.
  • On failure, rejects with an error object.
To access customer data after login has completed, use Smile.customer.current() . To access any of the resources that were preloaded as part of the login call, use their respective preloaded() methods.