How to combine react and api on asp.net core?

  • 0
    I wrote front and am trying to connect to the api using axios:
    I run api via vs, a page appears where data from the database is displayed in json format. And then they start the front through vsc (I write npm start). A page is opened on which no data is displayed.

    Maybe you need to somehow unite the front and the back?
    React Anonymous, Nov 7, 2019

  • 3 Answers
  • 0
    The backend implements logic that gives you data accessible through endpoints.

    All that needs to be done at the front is to receive this data and implement your own logic.

    Accordingly, if the front does not give you any data, then you did something wrong.

    Check through DevTools, in the Network XHR tab, requests. If you get the right answer, then you did something wrong at the front.



    And, as a rule, in the instance of axios as a base url, it is the base link that is indicated, that is, localhost: 44336 - link without pointing to some api endpoint. And already in the call to the get () method, the endpoint is indicated.
    Anonymous

  • 0
    Most likely the problem is CORS
    Lily Reilly

  • 0
    First, configure CORS. and secondly, you can transfer the react client to the studio project itself.
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!