首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在meteor中找不到"Astronomy/execute“方法

在meteor中找不到"Astronomy/execute“方法
EN

Stack Overflow用户
提问于 2021-03-15 14:44:21
回答 1查看 29关注 0票数 0

好的,我使用meteor中的天文包构建了游戏数据库模式。

然后,我尝试通过在服务器中扩展它来添加方法。(server/gamehandle.js)

代码语言:javascript
复制
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()
    }
  }
})

但是,当我尝试使用callMethod在应用程序客户端中运行该方法时,它抛出了一个错误:天文/执行未找到404。这是使用它的组件

代码语言:javascript
复制
import {Game} from '../../../db/game'

export function NewGameList(props){
  const { isOpen, onOpen, onClose } = useDisclosure()
  const [judul, setJudul] = useState('')
  const [hasil, setHasil] = useState(null)
  const judulChange = (e) => setJudul(e.target.value)
  const AddGame = new Game()
  
  const handleSubmit = (e) => {
    e.preventDefault()
    AddGame.callMethod('AddNewGame', judul, (err, result) => {
      result ? setHasil(result) : setHasil(err.message) 
      console.log(err)
    })
  }
...

照亮我,我做错了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-03-17 11:28:48

终于从流星松弛中找到了解决方案。只需要将我的db文件导入到服务器中的主js文件中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66633416

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档