SAP / gigya-react-native-plugin-for-sap-customer-data-cloud

A React Native plugin for interfacing SAP Customer Data Cloud. The plugin provides quick access to core elements & business API flows available within the SAP Customer Data Cloud designed for React Native mobile application.
Apache License 2.0
14 stars 11 forks source link

The `getAccount` and `getSession` methods don't return a JSON dictionary, but rather a JSON string #31

Closed bitcrumb closed 1 year ago

bitcrumb commented 2 years ago

Although the function definition of the Gigya.getAccount() and Gigya.getSession() methods have a TypeScript return type which defines that we should expect a GigyaDictionary (which is just a Record<>) or plain JS object, it instead returns a serialized JSON string.

getAccount(params?: Record<string, any>): Promise<GigyaDictionary>; // <- return type is incorrect
...
function getSession(): Promise<null | {sessionToken: string, sessionSecret: string, expirationTime: number}>;

This implies that we explicitly have to parse the response to a JSON dictionary using JSON.parse().

It would be better if the methods, in line with its definition, always returned a JSON dictionary object directly.

Given that these two methods return strings instead of JS objects... I suspect that this might be an issue with other methods as well?

DiegoSaa commented 1 year ago

Hello, I'm having the same issue, with the example const senddd = await Gigya.socialLogin("facebook"); typeof senddd -> is a string

tal-mi commented 1 year ago

Fixed in v 0.1.0