I couldn’t solve this basic error, and I haven’t changed anything in my code but fixing the indentation of if clauses
I make a request to Google Direction’s API and capture the total travelling duration by car between the points. I try to capture it by using the code below;
duration = hash['routes'][0]['legs'][0]['duration'].fetch('value')
However when I try to make a comparizon like below it gives me errors;
if duration < timeToArriveSecond #where timeToArriveSecond is a parameter started with value -1. Integer value
Would it be possible for developers here to enlighten me as I’m stuck.
hard to say without knowing how the hash looks like but since your ‘routes’ and ‘legs’ returns an array key ‘value’ of duration seems also to do so, try to change your line as follows:
or since fetch works like [“value”] here
for me ist seems that hash looks something like this (as far as i can tell how you access it: