AXIOS: How to render to HTML

Posted 1 year ago by marcellopato

I did a get request using axios and now I need to print the response to an DIV. Lets see some code:

AXIOS request:

mounted() {
      axios.get('/get-marcas').then(response => this.marcas = response.data);
}

VitrineController.php

public function getMarca()
    {
            $marcas = Marca::orderBy('descricao')->get();
            return response()->json($marcas);
     }

The method section:

methods: {
      umaMarca() {
        axios.get('/trocaCarros/' + marca.value).then(response => {
          const vitrine = response.data;
          return(vitrine);
          // response.render('vitrine');
        });
      },

The result is:

[{id: 880011, descricao: "Accord", marca_id: "212", categoria_id: "1", ativo: 1,…},…]
0
:
{id: 880011, descricao: "Accord", marca_id: "212", categoria_id: "1", ativo: 1,…}
1
:
{id: 880012, descricao: "City", marca_id: "212", categoria_id: "1", ativo: 1,…}
2
:
{id: 880013, descricao: "Civic", marca_id: "212", categoria_id: "1", ativo: 1,…}
3
:
{id: 880014, descricao: "CR-V", marca_id: "212", categoria_id: "1", ativo: 1,…}
4
:
{id: 880015, descricao: "Fit", marca_id: "212", categoria_id: "1", ativo: 1,…}
5
:
{id: 880016, descricao: "HR-V", marca_id: "212", categoria_id: "1", ativo: 1,…}

As I spected.

Now i want to render this looping on a HTML file. Anyone?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.