As part of my API setup, I am sending parameters to a python script. One of these parameters happens to be a JavaScript array. Interestingly, when I check the array in Python, it only shows the first index.
Here is the snippet of my Angular JS get request:
$http.get(
apiBase + '/deals/timeline', {
params: {
api_key: $scope.settings.apiKey,
start_date: startDate,
interval: interval,
amount: amount,
fieldKeys: $scope.settings.fieldKeys
}
})
And here is a glimpse of my Python code:
import config
import json
import requests
def api_deals_timeline(params):
start_date = params.get('start_date')
interval = params.get('interval')
amount = params.get('amount')
field_key = params.get('field_key')
print(field_key)
r = requests.get('url.com/?something={}&somelse={}'.format(start_date, interval))
if r.status_code == 200:
return json.loads(r.text)['data']
else:
return None
My Apache logs show the following statement for field_key:
[Thu Aug 14 16:23:56 2014] [error] [u'add_time', u'won_time', u'lost_time', None]
While the console.log output for $scope.settings.fieldKeys is:
["lost", "won", "new"]