[Solved] Method "Astronomy/execute" not found 404

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 NewGame(props){
  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 with my code? I am following the astronomy docs. Googling it but there is no problem about astronomy/execute not found. Changing it to add the methods directly to Class still have the same astronomy/execute not found.

Found the solution from the slack discussion.

It just need to import my db file to mainjs in server without calling the class

import '../imports/db/game'

The best implementation is by using Application Structure | Meteor Guide

1 Like

Glad you found a solution! Thanks for sharing it back here