Dealing with null values from Rest call in React/SPF

%3CLINGO-SUB%20id%3D%22lingo-sub-298881%22%20slang%3D%22en-US%22%3EDealing%20with%20null%20values%20from%20Rest%20call%20in%20React%2FSPF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-298881%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EApologies%20if%20this%20is%20the%20wrong%20forum%2C%20please%20correct%20me%20if%20so.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAm%20trying%20to%20get%20my%20head%20around%20using%20React%20in%20SharePoint%20Framework%20Dev.%20So%20far%20I'm%20surviving.%20But%20bit%20stuck%20now.%20Am%20making%20a%20Rest%20call%20to%20get%20SharePoint%20list%20data%2C%20including%20various%20lookups.%20I%20can%20get%20the%20data%2C%20including%20lookup%20values.%20However%2C%20for%20some%20of%20the%20lookups%20I%20get%20a%20null%20value%20(where%20a%20member%20of%20staff%20has%20not%20been%20assigned%20to%20a%20call%20for%20instance)%20and%20my%20results%20are%20not%20rendered%20as%20the%20code%20cannot%20find%20a%20value%20(cos%20it's%20null).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20question%20is%2C%20at%20what%20point%20should%20I%20be%20dealing%20with%20the%20null%20and%20how%3F%20I%20get%20json%20back%20initially%2C%20and%20then%20I%20turn%20that%20into%20an%20object%20array.%20I%20then%20pass%20it%20as%20props%20to%20my%20component%20and%20map%20it%20to%20my%20data%20model.%20At%20what%20stage%20of%20that%20process%20should%20I%20be%20checking%20for%20null%20values%20and%20manipulating%20them%3F%20If%20that%20is%20what%20I%20should%20be%20doing...%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20suggestions%20much%20appreciated.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPaul%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Contributor

Hello,

 

Apologies if this is the wrong forum, please correct me if so.

 

Am trying to get my head around using React in SharePoint Framework Dev. So far I'm surviving. But bit stuck now. Am making a Rest call to get SharePoint list data, including various lookups. I can get the data, including lookup values. However, for some of the lookups I get a null value (where a member of staff has not been assigned to a call for instance) and my results are not rendered as the code cannot find a value (cos it's null).

 

My question is, at what point should I be dealing with the null and how? I get json back initially, and then I turn that into an object array. I then pass it as props to my component and map it to my data model. At what stage of that process should I be checking for null values and manipulating them? If that is what I should be doing... 

 

Any suggestions much appreciated.

 

Paul

0 Replies