Language: EN


How to make an Api Rest with ESP8266 or ESP32, Axios, VueJs and Vuetify

We continue with our tutorials section of the ESP8266 and ESP32 seeing how to integrate an application that combines VueJs, Vuetify, Axios and communicates with the ESP8266 through a Rest API.

We will refer to the ESP8266, but the same code is compatible for the ESP32, adjusting the name of the libraries. At the end you have the code for both the ESP8266 and the ESP32.

In the previous entry of this series, we were integrating an application in VueJs, which used the Axios library to communicate through a Rest API with the ESP8266 acting as a backend.

Our application could be a good example of architecture but… let’s admit that it was ugly as sin. But this is about to change! To do this, we are going to incorporate Vuetify into our cocktail, which we already saw in this post.


The goal is to achieve functionality similar to the previous one, that is, a demo that shows how to perform the different actions through the Rest API, but with this more modern and suitable aesthetic.

Looks better, right? Well, let’s get to work. The backend code, that is, the ESP8266, is identical to the last two entries. So, again, I avoid copying it again and refer you to the previous entries or the code on Github.

What is going to change is the served web page.

The index.html file becomes

<!DOCTYPE html>
    <title>ESP8266 Vuetify + Axios</title>
    <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- From CDN -->
    <!--<link href=',400,500,700|Material+Icons' rel="stylesheet">-->
    <!--<link href="" rel="stylesheet">-->

    <link href="./vendor/google-fonts.css" rel="stylesheet">
    <link href="./vendor/vuetify.min.css" rel="stylesheet">
    <div id="app">
      <v-app id="inspire">
        <v-container style="max-width: 600px">
              <v-layout row>
                <v-flex xs12 sm6 md3>
                  <v-btn color="info" @click="getAll">Get All</v-btn>

              <v-layout row>
                <v-flex xs12 sm6 md3>
                  <v-btn color="info" @click="getById">Get</v-btn>

                <v-flex xs12 sm6 md3>
                  <v-text-field v-model.number="getId" label="Id" solo type="number"></v-text-field>

              <v-layout row>
                <v-flex xs12 sm6 md3>
                  <v-btn color="info" @click="updateById">Update</v-btn>

                <v-flex xs12 sm6 md3>
                  <v-text-field v-model.number="updateId" label="Id" solo type="number"></v-text-field>

                <v-flex xs12 sm6 md3>
                  <v-text-field v-model="updateText" label="Text" solo></v-text-field>

          <v-divider class="mb-3"></v-divider>

          <v-text-field v-model="newItem" label="Add new item" solo @keydown.enter="create">
            <v-fade-transition slot="append">
              <v-icon v-if="newItem" @click="create">add_circle</v-icon>

            <v-toolbar color="cyan" dark>
              <v-toolbar-title>Total: {{ items.length }}</v-toolbar-title>

            <v-fade-transition class="py-0" group tag="v-list">
              <template v-for="(item, i) in items">
                <v-divider v-if="i !== 0" :key="`${i}-divider`" ></v-divider>

                <v-list-tile :key="`${i}-${item.text}`">
                    <v-list-tile-title v-text=""></v-list-tile-title>


                      <v-list-tile-title v-text="item.text"></v-list-tile-title>

                    <v-btn color="error" v-model="item" @click="remove(item)">Delete</v-btn>

            <v-snackbar v-model="snackbar" :bottom="true" :timeout="timeout">
              {{ text }}
              <v-btn color="pink" flat @click="snackbar = false">

  <!-- From CDN -->
  <!--<script src=""></script>-->
  <!--<script src=""></script>-->
  <!--<script src=""></script>-->

  <script type="text/javascript" src="./vendor/vue.min.js"></script>
  <script type="text/javascript" src="./vendor/vuetify.min.js"></script>
  <script type="text/javascript" src="./vendor/axios.min.js"></script>
  <script type="text/javascript" src="./js/API.js"></script>
  <script type="text/javascript" src="./js/app.js"></script>

The JavaScript file of the page must also be modified to adapt to the new Vuetify Framework, as follows.

new Vue({
  el: '#app',
  data: () => ({
    items: [
        id: 0,
        done: false,
        text: 'Init 0'
    newItem: null,
    getId: null,
    updateId: null,
    updateText: null,
    snackbar: false,
    timeout: 1500,
    text: '',
    lastId : 0,
  computed: {
  methods: {
    create () {
      lastId = Math.max( =>;
        id: ++this.lastId,
        done: false,
        text: this.newItem
      this.newItem = null
    getAll() {
      this.text = "Getting all"
      this.snackbar = true
      lastId = Math.max( =>;
      this.items.push({id: ++this.lastId, text: 'Loaded all '})
      this.items.push({id: ++this.lastId, text: 'Loaded all '})
    getById() {
      if(this.getId == null) return;
      if(((typeof this.items.find(x => === this.getId) !== 'undefined'))) return;
      this.text = "Getting by Id " + this.getId
      this.snackbar = true
      this.items.push({id: this.getId, text: 'Loaded by Id'})
    updateById(id) {
      if(this.updateId == null || this.updateId == null) return;
      this.text = "Updating " + this.updateId + " with " + this.updateText
      this.snackbar = true
      API_put(this.updateId, this.updateText)
      this.items.find(x => === this.updateId).text = this.updateText
    remove(item) {
      this.text = "Deleting " +
      this.snackbar = true
      this.items.splice(this.items.indexOf(item), 1)


We upload our content to the SPIFFS as usual, and press the different buttons to check that everything works correctly in the browser’s development console.


As well as that they arrive correctly at the ESP8266 as a backend, through the serial port terminal.


And we have finished this series of tutorials! We have integrated a Rest API, Json, Axios, Vue, and Vuetify in a functional and beautiful demo app. You can be proud! (pat on the back)

So, are we done? Not at all. In the next three entries, we will see how to create an API for the ESP8266 that allows reading analog/digital inputs and performing actions, through Websocket, also using Vue on the frontend. See you soon!

Download the code

All the code from this post is available for download on Github.


Version for the ESP8266:

Version for the ESP32: