Method "Astronomy/execute" not found 404
ashlite opened this issue · comments
So I have a DB schema build using astronomy in my meteor webapp.
Then I extend it in my server/gameHandle.js to add a method to my db.
import {Game} from '../imports/db/game'
import {DDP} from 'meteor/ddp-client'
Game.extend({
meteorMethods: {
AddNewGame(judul){
const invocation = DDP._CurrentInvocation.get()
this.namaGame = judul
this.creator = invocation.userId
this.createdAt = new Date()
return this.save()
}
}
})
But when I try to call it in my component, it throw error that astronomy/excute not found.
Here are the code in my component
import {Game} from '../../../db/game'
export function xxxx.....{
const [judul, setJudul] = useState('')
const [hasil, setHasil] = useState(null)
const AddGame = new Game()
const handleSubmit = (e) => {
e.preventDefault()
AddGame.callMethod('AddNewGame', judul, (err, result) => {
result ? setHasil(result) : setHasil(err.message)
console.log(err)
})
}
Is there any wrong in my code? I am following the astronomy docs. Googling it but there is no problem about astronomy/excute not found
This is my latest repo https://github.com/ashlite/back-chamber
This error might appear when you didn't import Astronomy on both client and server. You have to make sure that it's imported. You might even do import { Class } from 'meteor/jagi:astronomy';
in your main file in both client and server to make sure that everything is loaded. And the error should go away. Let me know if it works
I tried to import import {Class} from 'meteor/jagi:astronomy' even tried using import 'meteor/jagi:astronomy'. In every js file in server, client main jsx, app jsx and my jsx component that use the class mentioned.
Still have the same error.
Tried removing and re-adding package still have the same issues.
Owh okay finally fix the problem.
Based on https://guide.meteor.com/structure.html#startup-files. I need to import my db file directly import 'imports/db/game'
to main js file in server instead of Importing meteor/jagi:astronomy. The better way of course implementing the guide above by making extra js file for "startups".