# What is the returned value if Datahub.read() is failled?

**URL:** <https://forum.sierrawireless.com/t/what-is-the-returned-value-if-datahub-read-is-failled/21953>\
**Category:** Octave\
**Created:** [October 29, 2020, 4:02am UTC](https://forum.sierrawireless.com/t/what-is-the-returned-value-if-datahub-read-is-failled/21953 "2020-10-29T04:02:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jameshorng](https://avatars.discourse-cdn.com/v4/letter/j/90db22/32.png) [@jameshorng](https://forum.sierrawireless.com/u/jameshorng)\
**Post date:** [October 29, 2020, 4:02am UTC](https://forum.sierrawireless.com/t/what-is-the-returned-value-if-datahub-read-is-failled/21953/1 "2020-10-29T04:02:09Z")

</div>

I got error message like “Cannot read property ‘value’ of null” when resource have no valid data to return. Can I check if valid data is available from datahub before I read it?

The following code is not working. Can someone show me the right way to do it?  
if (Datahub.read(’/location/coordinates/value’, 0).value != null) {  
loc0 = Datahub.read(’/location/coordinates/value’, 0).value;  
} else {  
return;  
}

---

<div class="post-metadata">

**Author:** ![amons](https://sea1.discourse-cdn.com/flex025/user_avatar/forum.sierrawireless.com/amons/32/4887_2.png) [@amons](https://forum.sierrawireless.com/u/amons)\
**Post date:** [October 30, 2020, 3:24pm UTC](https://forum.sierrawireless.com/t/what-is-the-returned-value-if-datahub-read-is-failled/21953/2 "2020-10-30T15:24:03Z")

</div>

> [@jameshorng](#):
>
> if (Datahub.read(’/location/coordinates/value’, 0).value != null)

Removing the .value should work as the returned object is (Datahub.read(’/location/coordinates/value’, 0)  
which has a .value and a .ts key if not empty, but non of them if empty

This should work as you expect:  
if (Datahub.read(’/location/coordinates/value’, 0) != null)

---

<div class="post-metadata">

**Author:** ![jameshorng](https://avatars.discourse-cdn.com/v4/letter/j/90db22/32.png) [@jameshorng](https://forum.sierrawireless.com/u/jameshorng)\
**Post date:** [October 31, 2020, 5:14am UTC](https://forum.sierrawireless.com/t/what-is-the-returned-value-if-datahub-read-is-failled/21953/3 "2020-10-31T05:14:11Z")

</div>

This solved my problem. Thanks a lot for the suggestion.

James
