Skip to content

Commit

Permalink
Fixed crops fetch problem
Browse files Browse the repository at this point in the history
  • Loading branch information
dallascrichmond committed Jan 28, 2025
1 parent 5ed244c commit da3db31
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions backend/apps/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def cropTypes(self, request, pk=None):
def crops(self, request, pk=None):
crops = Crops.objects.all()
serializer = CropsSerializer(crops, many=True)
return Response(serializer.data, status=status.HTTP_200_OK)
@action(detail=True, methods=['get'])
def animals(self, request, pk=None):
animals = Animals.objects.all()
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/views/FieldAndSoil/Crops/Crops.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ export default function Crops({ fields, setFields }: FieldListProps) {
}
});
apiCache.callEndpoint('api/crops/').then((response: { status?: any; data: any }) => {
const { data } = response;
setCropsDatabase(data);
if (response.status === 200) {
const { data } = response;
setCropsDatabase(data);
}
});
}, []);

Expand Down

0 comments on commit da3db31

Please sign in to comment.