1

I'm currently stuck on a problem, I would like to be able to return what the fetch receives, for example:

{"data": [{"account_id": 134519399, "account_url": "Pseudo", "ad_type": 0, "ad_url": "", "animated": false, "bandwidth": 110238, "datetime": 1603190775, "deletehash": "Mg3FROsdfPF7N", "description": null, "edited": "0", "favorite": false, "has_sound": false, "height": 368, "id": "3HzN2Ye", "in_gallery": false, "in_most_viral": false, "is_ad": false, "link": "https://i.imgur.com/lbWS8uo.jpg", "name": "unnamed.jpg", "nsfw": null, "section": null, "size": 55119, "tags": [Array], "title": null, "type": "image/jpeg", "views": 2, "vote": null, "width": 512}], "status": 200, "success": true}

but I'm currently receiving this:

{"_U": 0, "_V": 0, "_W": null, "_X": null}

Here's my code:

export default async function FetchImage(access_token, path_query) {
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer " + access_token);

var formdata = new FormData();
var imageRec

var requestOptions = {
    method: 'GET',
    headers: myHeaders,
    redirect: 'follow'
};
return fetch("https://api.imgur.com/3/account/me/images", requestOptions)
    .then(response => response.json())
    .catch(error => console.log('error', error))
}

And I call my function in this class :

var ress;
    export default class ImageNav extends Component {
    constructor(props) {
        super(props);
    }
 
    _getAccessToken() {
        var res = this.props.navigation.state.params.access_token;
        return res
    }
 
    render() {
        // console.log(this._getAccessToken())
        ress = FetchImage(this.props.navigation.state.params.access_token)
        console.log(ress)
        return (
            <>
                <View>
                    <Text>access_token: {this._getAccessToken()}</Text>
                </View>
                <View style={styles.buttonFav}>
                    <Button buttonStyle={{ backgroundColor: '#4D4D4D' }} title="FavNav" onPress={() => this.props.navigation.navigate('FavNav')}></Button>
                </View>
                <View style={styles.buttonFind}>
                    <Button buttonStyle={{ backgroundColor: '#4D4D4D' }} title="FindNav" onPress={() => this.props.navigation.navigate('FindNav')}></Button>
                </View>
            </>
        )
    }
}

I've looked on forums, but I can't find a solution.

If someone can help me,

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
HugoTek
  • 41
  • 5

0 Answers0