I am having trouble finding a solution that works for me.
Currently, I am using python 3.6 (Django Rest Framework) on the server side and Angular 5 on the client side.
This is the code on the server:
class TypesView(APIView):
def get(self,request):
a = ['Cat','Dog']
j = json.dumps(a)
return Response(data=j, status=status.HTTP_200_OK)
I am attempting to parse this data on the client side:
public getAnimalRaces(): Observable<string[]>{
const path = environment.apiEndpoint + "animals/races/"
return this._http_client.get<string[]>(path)
}
However, I keep encountering the following error: Error trying to diff '["Cat", "Dog"]'. Only arrays and iterables are allowed
This is what is being returned to the client:
"[\"Cat\", \"Dog\"]"
Any suggestions or ideas on how to resolve this issue?