I am working in Angular and I am using Http Request and Response. Is it possible to send multiple arguments in 'Response'.
Angular file:
this.http.get("api/agent/applicationaware").subscribe((data:any)...
python file:
def get(request):
...
return Response(serializer.data)
I want to send multiple arguments in the Response. Like
return Response(serializer.data,obj.someothervalue)
can you help me with this? Thanks in advance :)
You can return a dictionary
return Response({'serializer_data': serializer.data, 'some_other_value': obj.someothervalue})
Or you can append someothervalue to serializer.data
data = serializer.data
data['someothervalue'] = obj.someothervalue
return Response(data)
If obj.someothervalue is a dictionary as well, then you can merge two dictionaries:
data = serializer.data.copy()
data.update(obj.someothervalue)
return Response(data)
add a dictionary
dict = {}
dict['details'] = serializer.data
dict['other'] = someotherdata
return Response(dict)
hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With