import { createAjaxRoute, lessThanThreeErrors } from '../utils/apiHelpers' interface AuthenticateArgs { apiBaseUrl: string authParams: any } export const authenticate = ({ apiBaseUrl, authParams, }: AuthenticateArgs) => { return createAjaxRoute({ url: `${apiBaseUrl}/api/auth`, method: 'POST', body: JSON.stringify(authParams), }) .retryWhen(lessThanThreeErrors) .map((data) => { return { userIpAddress: data.response.remote_ip, userId: data.response.user_id, sessionToken: data.response.session_token, } }) }