PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Blocks

    Design blocks for your website

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Vue Mixin, Axios

export default {
    data() {
        return {

        }
    },
    methods: {
        async callApi(method, url, dataObj) {
            try {
                return await axios({
                    method: method,
                    url: url,
                    data: dataObj
                });
            } catch (e) {
                return e.response
            }
        }
    }
}

Mixin to easily call api in vue js

BETA Snippet explanation automatically generated by OpenAI:

Here is what the above code is doing:
1. Import axios module
2. Create a method callApi
3. Call axios with the method, url and data object
4. Return the response

Now, we will use this code in our code.js file.

##

Snippet By Wamae Arnold

ยท

Created March 11th, 2022

ยท

Report Snippet