I have a challenge. I can not use dynamic variable in dictionary.
selectedtei is a function the parameter. Using it with the dictionary recognizes it as empty
eg
const sb = `${selectedtei}` //does not work
const sb = selectedtei //does not work
// checking the output in console for both
console.log(sb) displays the accurate variable value - SBjuNw0Xtkn
const sb = "SBjuNw0Xtkn" works
// checking the output in console
console.log(sb)
I checked the typeof, all string
const getSelected = {
targetedSelected:{
resource: 'trackedEntityInstances',
params: {
trackedEntityInstance: sb
},
},
}
I have also used the approach passing the variable as an argument with userDataQuery and the result are all the same below…
const query = {
results: {
params:({trackedEntityInstance}) => ({
trackedEntityInstance: trackedEntityInstance
}),
},
}
/** does not work ***/
const { loading, error, data } = useDataQuery(query, {
variables: {
trackedEntityInstance: selectedtei
}
})
/** works ***/
const { loading, error, data } = useDataQuery(query, {
variables: {
trackedEntityInstance: “SBjuNw0Xtkn”
}
})
Can some body help me use dynamic variable.