livechat / chat-widget-adapters

This project contains a set of libraries for adapting LiveChat Chat Widget with certain frontend frameworks
https://developers.livechat.com
MIT License
24 stars 8 forks source link

How to get baseAPI when use customIdentityProvider #86

Open cydd007 opened 11 months ago

cydd007 commented 11 months ago

customIdentityProvider() { const baseAPI = '' //////what is this value???? const userId = '30317220-c72d-11ed-2137-0242ac120002'

            const getToken = async () => {
              const response = await fetch(`${baseAPI}/getToken/${userId}`)

              const token = await response.json()
              console.log('getToken', token)
              return token
            }

            const getFreshToken = async () => {
              const response = await fetch(`${baseAPI}/getFreshToken/${userId}`)

              const token = await response.json()
              console.log('getFreshToken, token')
              return token
            }

            const hasToken = async () => {
              const response = await fetch(`${baseAPI}/hasToken/${userId}`)
              const data = await response.json()
              return data
            }

            const invalidateToken = async () => {
              const response = await fetch(`${baseAPI}/invalidate/${userId}`)
              const data = await response.json()
              console.log(data)
            }

            return {
              getToken,
              getFreshToken,
              hasToken,
              invalidate: invalidateToken,
            }
          },