Skip to content

Setup issues with vue3 - Item.api is not a function #135

@7ammer

Description

@7ammer

Hello 👋

vuex-orm and this plugin look great! Thanks for building it. However, I'm having a lot of trouble setting it up locally.
I'm using:

  • "vue": "^3.0.5",
  • "vuex": "^3.6.2",
  • "@vuex-orm/core": "^0.36.3",
  • "@vuex-orm/plugin-axios": "^0.9.4",

This is how I've set it up...

....
import VuexORM from '@vuex-orm/core'
import Item from '@/models/Item'
import Vuex from "vuex"

import VuexORMAxios from '@vuex-orm/plugin-axios'
import axios from 'axios';

VuexORM.use(VuexORMAxios, { axios })

// Create a new instance of Database.
const database = new VuexORM.Database()


// Register Models to Database.
database.register(Item);

// Create Vuex Store and register database through Vuex ORM.
const store: any = new Vuex.Store({
  plugins: [VuexORM.install(database)]
})

const app = createApp(App)
  .use(store)
  .use(IonicVue)
  .use(router);

router.isReady().then(() => {
  app.mount('#app');
});

I have created a simple model and am calling the api method like so:
await Item.api().get('https://example.com/api/users')

This unfortunaly produces these errors:
Uncaught Error: [vuex] must call Vue.use(Vuex) before creating a store instance.
and
Item.ts?93a1:53 Uncaught (in promise) TypeError: Item.api is not a function

Does this plugin support vue3?

Thanks :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions