Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have below code snippet which is giving me an error. I am getting a response back from getFilteredList which is of lenght 1 and it has a proper json data. But not sure why its giving error.

TypeError: Cannot read property 'then' of null


getFilteredList(group, feature).then(r=>{ //here I am getting error. 
    if(r.data.response_code == "1")
    {
      const columnName = "ColumnName";
      const Codes = r.data.response_message.map(x => x[columnName]);
      Codes.forEach(code => {
        let store = getStoreValue(code);
        getDetailsById(id, datastore)
        .then(r=>{
          res.status(200).send(r.data);
        }).catch(e=>{
          parseError(e, res);
        });
      })
    }
  }).catch(e=>{
      parseError(e, res);
    });
}


What I have tried:

getFilteredList() a another node js service which is returning a data when I tested it using Saop UI. I can see it in logs as well of application. I am not getting why it is saying null though having a data
Below is sample data it returns.
{"CODE":"AGR","GRP":"LEND","FEAT_CODE":"SRC_AGREE","GROUP_NAME":"Prop","FEA_NAME":"Property","DISPLAY_NAME":"Property","ROLE_CODE":"LE"}
Posted
Updated 13-Feb-20 3:26am
v3

1 solution

JavaScript
getFilteredList(group, feature).then(r=>{

The message simply means that the call to getFilteredList does not return anything.
 
Share this answer
 
v2
Comments
Telstra 13-Feb-20 9:01am    
But this same call is working in my one more node js service where this call is returning a data.
getDetailsById(adgroup, featureSet).then(r=>{ -- this line is working fine here.
if(r.data.response_code == "1") -- this condition is working fine.
{
}
Richard MacCutchan 13-Feb-20 9:09am    
Sorry I copied the wrong line of your question; see updated code above. You need to use your debugging tools to find out why it does not return anything.
Telstra 13-Feb-20 9:11am    
getFilteredList() is another node js service which itself returns json data and I can see that data in logs. Below is the data it returns.

{"CODE":"AGR","GRP":"LEND","FEAT_CODE":"SRC_AGREE","GROUP_NAME":"Prop","FEA_NAME":"Property","DISPLAY_NAME":"Property","ROLE_CODE":"LE"}
F-ES Sitecore 13-Feb-20 9:58am    
You might think that is what it is returning, but it isn't, it is returning null, ergo the error.
Telstra 13-Feb-20 10:16am    
I got that response from logs and I can see that in json string variable as well from getFilteredList() service.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900