Using CustomJS to make API call don't return a correct object

Hello. I’ve been trying to find a way to use AjaxDataSource to retrieve a JSON object. I used CustomJS model to convert the object into a bokeh format but it’s not working as excepted.
Here the code:

    adapter = CustomJS(
    code = """
    const result = {
        date:[], 
        open:[], 
        close:[], 
        high:[], 
        low:[]
        };
    const time_series = cb_obj.response["Time Series (5min)"];
    for(date in time_series){
        result.date.push(date);
        result.open.push(time_series[date]['1. open']);
        result.high.push(time_series[date]['2. high']);
        result.low.push(time_series[date]['3. low']);
        result.close.push(time_series[date])['4. close'];
        }
    console.log(result);
    return result;
    """)

source = AjaxDataSource(data_url='https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=AAPL&interval=5min&apikey=API_KEY',
                    polling_interval=100, adapter=adapter)

print("Here is source : ",adapter)

increasing = source.close > source.open
decreasing = source.open > source.close

Error

'AjaxDataSource' object has no attribute 'close'
Variable 	Value
adapter 	

CustomJS(id='1001', ...)

request 	

<WSGIRequest: GET '/'>

source 	

AjaxDataSource(id='1002', ...)

What are these lines for?

Thanks for the quick reply.
These lines are there to color the red and green bars for down and up days.

OK. But they’re the ones that causing the problem. source doesn’t have close or open attributes. It has data attribute which might have the keys (not attributes) close and open, if the data available by that URL has them. And even then, the data will not be available right when you create the data source - it will be available only after some time the web page is rendered.

Thanks! I resolved my problem.