'Trying to retrive JSON Array through fetch in react native but JSON parse error:Unreconised token "<"

In the code,i am fetching the token from expo-secure-store,later fetching the API data from fetchdata function.But unfortunately error "unrecognized token" is displayed.

After the error is displayed,the API call returns JSON Array data.Unable to do data map in react native to TradeCard Component.

import { StatusBar } from 'expo-status-bar';
import {React,useState,useEffect} from 'react';
import TradeCard from './TradeCard';
import { StyleSheet, Text, View,TextInput,TouchableOpacity,ScrollView,ActivityIndicator } from 'react-native';
import * as SecureStore from 'expo-secure-store';
export default function Trades()
{
    const [ data,setData] = useState([]);
    const [ isLoading,setLoading] = useState(true);
    const [user,setUser] = useState('');
    const [token,setToken] = useState('');
    const fetchTokens = async () => {
        try {
            const user = await SecureStore.getItemAsync('user');
            const token = await SecureStore.getItemAsync('token');
            setUser(user);
            setToken(token);
            if (user && token)
            {
                fetchData();
            
            }
            else
            {
              
            }
        } catch (e) {
            alert('Error',e);
        }
    }
    useEffect(()=>{ fetchTokens()},[]);
    
    const fetchData = async () => {

            setLoading(true);
            
            fetch('https://tradecoaster.herokuapp.com/api/v1/listTrades/'+user+'/',
            {
                method:'GET',
                headers:{
                    'Accept':'application/json',
                    'Content-Type':'application/json',
                    'Authorization':'token '+token
                }
            })
            .then(res => res.json())
            .then((res)=>{
                console.log('Data',res);
                setData(res);
                setLoading(false);
            })
            .catch((error)=>{
                setLoading(false);
                alert(error);
                console.error("Error",error);
            });
        
    }
    return(
        <ScrollView>
            <View>
                {isLoading && data.length==0 ? <ActivityIndicator size="large" color="#0000ff" /> :
                    <Text>No Trades</Text>
                   }   
                       
                    

        
            </View>         
        </ScrollView>
    );
}```


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source