Class BazaarApp

The primary class of the Bazaar JS SDK to help you more easily build web apps with Bazaar.

Constructors

Properties

api: API

A wrapper of the low level Data API

auth: Auth

Auth handles authentication and login

bazaarUri: string = bazaarUri
collections: CollectionsAPI

Access to the collections API

notifications: NotificationsAPI

Access to the notifications API

orgs: OrganizationsAPI

Access to the organizations API

permissions: PermissionsAPI

Access to the permissions API

social: SocialAPI

Access to the social API

Methods

  • Gets a collection interface (API access to the specified collection)

    Type Parameters

    Parameters

    • collectionName: string

      The name of the collection to create the interface for.

    • Optional collectionOptions: CollectionOptions

      An optional object for specifying an onCreate hook. The onCreate hook sets up a collection when it is created (e.g., to set up permissions)

    Returns CollectionAPI<T>

  • Checks if the user is logged in. i.e. if an access token is in local storage.

    Returns boolean

  • Logs out a user. Deletes the access token from local storage and reloads the page.

    Returns void

  • Opens a pop-up window to perform OAuth login. Will fallback to redirect login if pop-up fails to open, if options.type is not popup (meaning an app has explicitly opted out of falling back to redirect login)

    Parameters

    Returns Promise<void>

  • Sets a callback function an app can run when it connects or re-connects to the API.

    Parameters

    • f: ((bzr) => Promise<void>)
        • (bzr): Promise<void>
        • Parameters

          Returns Promise<void>

    Returns void

  • Sets a callback function an app can run when an API disconnection occurs.

    e.g. Invalid access token

    Parameters

    • f: ((bzr, message) => Promise<void>)
        • (bzr, message): Promise<void>
        • Parameters

          Returns Promise<void>

    Returns void

  • Sets a callback function an app can run when a user has successfully logged in.

    e.g. Set state, redirect, etc.

    Parameters

    • f: ((bzr) => Promise<void>)
        • (bzr): Promise<void>
        • Parameters

          Returns Promise<void>

    Returns void

  • Sets a callback function an app can run a login error occurs.

    e.g. Authorization code is invalid

    Parameters

    • f: ((bzr, message) => Promise<void>)
        • (bzr, message): Promise<void>
        • Parameters

          Returns Promise<void>

    Returns void