Closed balpal4495 closed 6 years ago
Hi @balpal4495, sorry for the late response. Can you show me your current usage of getAllFeatureFlags
? We currently use that function at TrueCar and it works as expected for us.
Just to add, getAllFeatureFlags
does require the args key, user
, key
being your LaunchDarkly client ID and user
being the LaunchDarkly user
object as defined here: https://docs.launchdarkly.com/docs/js-sdk-reference#section-users
@jacobmoretti Thanks for your response, I was trying to use getAllFeatureFlags by wrapping it in a an async/await function within my react component. and passed the user and key to it in the parameters, but i simply kept getting back an empty object.
Your use case shouldn't be a problem. Do you mind sharing the code of your implementation? We use getAllFeatureFlags
successfully in the exact same way with async/await. Curious why this is failing for you.
so i would be using it in this way.
import { getAllFeatureFlags } from 'react-launch-darkly';
export const getFlags = async (user) => {
cost response = await getAllFeatureFlags(user)
return response;
}
This just returns back an empty object
getAllFeatureFlags
takes two args: https://github.com/TrueCar/react-launch-darkly/blob/master/src/lib/utils.js#L82
The first argument needs to be your LaunchDarkly client id. Second argument is the user
object.
So i tried that and it didn't seem to make any difference.
import { getAllFeatureFlags } from 'react-launch-darkly';
export const getFlags = async (clientId, user) => {
cost response = await getAllFeatureFlags(clientId, user)
return response;
}
I receive a
I checked the docs on launchdarkly , and they specify that a user is sent as a parameter to get allFlags.
so should the user
not be added to the params on this line https://github.com/TrueCar/react-launch-darkly/blob/b99c6fd894bf593b186b8c799240dda5aee95d34/src/lib/utils.js#L86
?
ok, never mind that, i figured it out.
i was using using a user id for the key and it should have been like this.
solution if anybody is stuck on the same issue.
getAllFeatureFlags(clientId, { key: user } )
Ahh yes that would be a problem. Those two args are described here: https://github.com/TrueCar/react-launch-darkly#props. At the moment getAllFeatureFlags
is undocumented, mostly because I've been trying to come up with a solution for it where you don't have to pass the client id and user object.
Closing this issue as its been resolved.
i know that there is a function called
getAllFeatureFlags
in the utils file, but this doesn't seem to be working correctly.