[Vuejs]-How can I connect my front end to my individually created backend

1👍

The first thing you need to do is open the back end CORS settings.
It connects to an endpoint on the Vue side, you can use axios framework to pull data
Here is an example
https://www.freecodecamp.org/news/how-to-build-an-spa-with-vuejs-and-c-using-net-core/

0👍

All you need to do is call the backend via API. Get the data via GET method, send the data via POST method. Let’s say you want to get person list from the backend. You can do this –

 const response = await fetch('https://yourawesomebackend.com/api/person/getpeople');
                    const content = await response.json();
// Now manipulate the DOM with the response.

In your backend, you might want to do this –

[Route("api/[controller]/[action]")]
[ApiController]
public class PersonController : ControllerBase
{
    public IActionResult GetPeople()
    {
        // read people from database
        var people = getFromDatabase();
        return Ok(people);
    }
}

Hope this helps.

Leave a comment