UNPKG

@prass/botpress-native

Version:

A simple and powerful SDK for integrating Botpress Chat API with React Native,

32 lines (29 loc) 944 B
import { prepareHeaders } from '../../utils/prepareHeaders.js'; import { handleError } from '../../utils/errorHandler.js'; /** * Internal handler for retrieving the current user's details. * @param this - Botpress instance context * @returns Promise resolving to the user's details * @throws Error if user key is missing or API call fails */ async function handleGetUser() { if (!this.userKey) throw new Error(this.errors.userNotCreated); try { const url = this.ChatApiBaseUrl.getUrl(["users", "me"]); const { data } = await this.axiosInstance.request({ url, method: "GET", headers: prepareHeaders({ "x-user-key": this.userKey, }), timeout: this.config.timeout, }); return data; } catch (e) { return handleError(e, "GetUser"); } } export { handleGetUser }; //# sourceMappingURL=getUser.js.map