A
A
Alex102142020-01-24 19:48:45
JavaScript
Alex10214, 2020-01-24 19:48:45

I can not get data from the site, who can help a newbie?

Hello, please help me to get json.
Here is the site:
open-notify.org/Open-Notify-API/ISS-Location-Now
Here is my code:

import React, { Component } from 'react';

export default class Position extends Component {

    gettingPosition = async () =>{
        const api_url = await fetch('http://api.open-notify.org/iss-now.json');
        console.log(api_url)
    }

    render() {
        return (
                
        )
    }
}

Please tell me what I'm doing wrong, there are no errors in the console, but the data is not displayed in the console either. I'm new to this, but I really want to figure it out. (.json highlighted in black because it disappeared during the preview)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Robur, 2020-01-24
@Alex10214

.json highlighted in black because it disappeared during preview

And it disappeared because you do not use the code tag, which causes irritation among others and generally breaks the rules.
On the topic - look in the devtools for a request to the server to begin with - what went, what came.
Maybe your gettingPosition is not called at all

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question