I can not understand how to interact with the server.

http: // localhost / - display the index.html layout

http: // localhost / men - I get JSON for this request

But if I go directly to the link http: // localhost / men , then index.html is not given and instead of layout I have data.

I can not understand how I simultaneously receive and layout and data

    1 answer 1

    You need to add javascript index.html page, which accesses the server data and process it, for example, using fetch :

     fetch('http://localhost/men') .then(response => response.json()) .then(data => { console.log(data); }) .catch(err => console.error(err)); 
    • but I am doing so - Dmitry Filippov
    • @DmitryFilippov then I do not understand what you can’t do - Stranger in the Q
    • server returns when prompted localhost / men json. not index.html. Therefore, if you refresh the page with this url localhost / men , then the screen will be json - Dmitry Filippov
    • @DmitryFilippov but you don’t need to follow this url, you need to access it only from a script - Stranger in the Q
    • and if necessary? Not always come to the site from the main page - Dmitry Filippov