Skip to content
Advertisement

Retrieve JSON Value error Undefined offset: 0

I have been having a hard time retrieving eth Value from a Json url for a while now, it keeps returning the error “Undefined offset: 0” as easy as it may be to anyone giving the answer, please consider that i am a learner and upcoming. My code below

JavaScript

Advertisement

Answer

The response from the url is something like

JavaScript

Few things from above output

  • There’s no [0] as you are trying to extract
  • since this seems to be PHP which supports heterogeneous arrays, you need to access it via value of the contract_address parameter passed in url since that is the key in the result object.

Putting it altogether.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement