M
M
Moro Zota2018-05-22 21:19:21
Flask
Moro Zota, 2018-05-22 21:19:21

How to get data in react component?

There is a code in flask:

from flask import Flask, jsonify

app = Flask(__name__)

i = [
    {
        'id': 1,
        'title': 'Hello'
    },
    {
        'id': 2,
        'title': 'World'
    }
]

@app.route('/', methods=['GET'])
def get_task():
    return jsonify({'i': i})

if __name__ == '__main__':
    app.run(debug=True)

with an array that I want to display in the component.
actually in react, I use componentDidMount . But I don’t understand what needs to be written here
and the
server is also wounded on the localhost. In package json I put proxy: port number is
that correct?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question