-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setup issues with vue3 - Item.api is not a function #135
Comments
Just to add.
Vuex no longer complains but I'm still seeing this error: |
Seeing a similar error, having upgraded to latest drafts of VuexORM and this plugin:
Here's my store setup:
and the component where I am trying to use it:
Results in the following:
|
This plugin is still under development and does not contain any functionality found in the current stable release as of yet (hence I think we need to make note of this in the repo to avoid further confusion. That said, as soon as vuex-orm-next is in a good place we can start focusing on the ecosystem. |
Yesterday I've had the same issue. After changing the order of the setup in the applications bootstrap process it worked fine. Here's my import Vue from 'vue'
import Vuex from 'vuex'
import VuexORM from '@vuex-orm/core'
import VuexORMAxios from '@vuex-orm/plugin-axios'
import Employee from '~/vue/models/employee'
import axios from 'axios'
Vue.use(Vuex);
VuexORM.use(VuexORMAxios, {
axios,
baseURL: '/api/'
});
const database = new VuexORM.Database();
database.register(Employee);
const store = new Vuex.Store({
plugins: [VuexORM.install(database)]
});
export default store And the import Vue from 'vue'
import store from '~/vue/store'
import EmployeeForm from './employee.vue'
if (document.getElementById('vue-employee-form')) {
new Vue({
el: '#vue-employee-form',
render: (bootstrap) => bootstrap(EmployeeForm),
store,
});
} Related dependencies locked at:
|
Thanks @cuebit, I guess as much. Will keep an eye out for updates and just manually fetch my data in the meantime. |
I am confused. As far as I understand, plugin-axios 0.9.4 is not compatible with Vuex 4? The last commit for plugin-axios-next was almost a year ago, is this package abandoned? As far as I understand, the minimum functionality is not supported. No way to use plugin-axios with VueJS 3, Vuex 4? |
@entermix, yep, that is pretty much what cuebit explained above. You're not missing anything. Charl13 is using the older line-up at present, according to his dependency versions. I am proceeding on Vue3/Vuex4/Vuex-ORM-next without this plugin for the time being. |
plugin-axios is a plugin for Vuex ORM, not Vuex/Vue. It's compatibility is irrelevant to the version of Vue/Vuex. However, it's compatibility is dependent on the version of Vuex ORM. 0.9.4 supports vuex-orm, not vuex-orm-next. Both iterations are compatible with Vuex 4.
It's not abandoned. It's currently not in a position to have core features implemented since they have yet to be finalised. Moreover, the state of vuex-orm-next is being addressed, minimum functionality will therefore encounter breaking changes quantitively while its dependent repo undergoes continued adoption. To reiterate, the fundamentals of this plugin behave as a wrapper for axios. The underlying functionality of the plugin reduces the arduous nature of handling requests/responses. That said, the simplicity of using axios with vuex-orm-next is by passing your response data to the desired persisting method (insert, update, etc). The repository pattern introduced in vuex-orm-next makes this a walk in the park. For example: import axios from 'axios'
import { Repository } from '@vuex-orm/core'
class UserRepo extends Respository {
use = User
async fetch() {
const { data } = await axios.get('...')
this.fresh(data.data)
}
} |
That's awesome! We love gathering feedback from users adopting the next branch as to help improve current (and pending) features. Feel free to drop this into the Slack channel at your leisure 👍 |
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:
This is how I've set it up...
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 :)
The text was updated successfully, but these errors were encountered: