Meteor.call returns undefined.
I do not see why.
-
I wish to return an object. Could it be because of the method return syntax? I also tried ({}).
-
Could it be because internal JSON like that has a slightly different syntax between Meteor and Vue.js or JavaScript?
Thanks, Marc
If I replace the call by a value, my value is assigned to the variable
(SEE: //HERE IS THE CALL):
main.js
import { Meteor } from 'meteor/meteor' //server methods
//import 'vue-clicky'
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
import VueMeteorTracker from 'vue-meteor-tracker'
Vue.use(VueMeteorTracker)
Vue.config.meteor.freeze = true
import GrapherVue from 'meteor/herteby:grapher-vue'
Vue.use(GrapherVue)
import lodash from 'lodash'
_ = lodash
const store = new Vuex.Store({
state: {
appStruc:{},
count: 10
},
mutations: {
increment (state) {
state.count++
},
loadAppStructure(state) {
state.appStruc=Meteor.call('appStructure') //HERE IS THE CALL
},
}
})
new Vue({
el: '#app',
store, //inject store in all children components
render: h => h('layout')
})
store.commit('loadAppStructure') //HERE IS THE CALL
/server/ServerMethods)
Meteor.methods({
appStructure() {
return ({
root:[
{i:'head', style: {gridArea:'head',
backgroundColor:'#00ff00',
gridArea:'1/1/1/4'}},
{i:'leftSideBar',style:
{gridArea:'leftSideBar',backgroundColor:'#0000ff',
gridArea:'2/1/3/2', width:'200px', height:'400px'}},
{i:'middle',style:{gridArea:'middle',backgroundColor:'#ffff00',
gridArea:'2/2/3/3',width:'auto'}},
{i:'rightSideBar',style:
{gridArea:'rightSideBar',backgroundColor:'#b0a0a0',
gridArea:'2/3/3/4', width:'200px', height:'200px'}},
{i:'footer',style:{gridArea:'footer',backgroundColor:'#a0c0a0',
gridArea:'3/1/4/4'}}
]
})},
});
Could it be because I do not include the method module the right way?
I do:
import { Meteor } from 'meteor/meteor' //server methods
but the file is in server side anyway. I suppose Meteor includes all server folders automatically. Is it the real purpose of this line?