Error message "TypeError: invalid 'in' operand context" when trying to create aps/Grid
Modified on: Sat, 18 Nov 2023 5:31 AMOriginal Publishing Date:
2020-01-22
2020-01-22
Symptoms
I'm trying to display data in aps/Grid, to do this I call custom operation and feed it into aps/Memory but there is an error:
TypeError: invalid 'in' operand context
context = (p in context ? context[p] : (create ? context[p] = {} : undefined));
Cause
aps.js library expects data property for aps/Memory to be an array of objects, it attempts to iterate over it to extract the data:
getProp = function(/*Array*/parts, /*Boolean*/create, /*Object*/context){
var p, i = 0, dojoGlobal = dojo.global;
if(!context){
if(!parts.length){
return dojoGlobal;
}else{
p = parts[i++];
try{
context = dojo.scopeMap[p] && dojo.scopeMap[p][1];
}catch(e){}
context = context || (p in dojoGlobal ? dojoGlobal[p] : (create ? dojoGlobal[p] = {} : undefined));
}
}
while(context && (p = parts[i++])){
context = (p in context ? context[p] : (create ? context[p] = {} : undefined));
}
Most probably data
is a string.
Resolution
Verify that result of querying the store are in proper JSON format.