gpt4 book ai didi

javascript - Meteor 应用程序在调用方法时崩溃

转载 作者:行者123 更新时间:2023-11-28 07:06:04 25 4
gpt4 key购买 nike

我有一个集合,其中使用以下代码插入了多个文档:

Projects.insert({
source: "https://upload.wikimedia.org/wikipedia/commons/7/7f/Pug_portrait.jpg",
title: "Pug",
artist: "pug",
description: "This piece shows the duality of pug",
price: "$50"
});

Projects.insert({
source: "http://c.fastcompany.net/multisite_files/fastcompany/poster/2014/01/3025003-poster-p-dog-2.jpg",
title: "Dog",
artist: "dog",
description: "much doge, many deal with it, wow",
price: "$50"
})

Projects.insert({
source: "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ea/Van_Gogh_-_Starry_Night_-_Google_Art_Project.jpg/1280px-Van_Gogh_-_Starry_Night_-_Google_Art_Project.jpg",
title: "Starry Night",
artist: "van gogh",
description: "night sky with stars",
price: "$75"
})

Projects.insert({
source: "http://totallyhistory.com/wp-content/uploads/2012/03/The_Scream.jpg",
title: "Scream",
artist: "edvard",
description: "scream",
price: "$50"
})

Projects.insert({
source: "https://www.petfinder.com/wp-content/uploads/2012/11/dog-how-to-select-your-new-best-friend-thinkstock99062463.jpg",
title: "Dog 2",
artist: "Bittu",
description: "This is a test to see how an actual thing would work",
price: "$50"
})

我创建了以下方法:

Meteor.methods({
addProject: function (source, title, artist, description, price) {
// Make sure the user is logged in before inserting a task
if (! Meteor.userId()) {
throw new Meteor.Error("not-authorized");
}

Projects.insert({
source: source,
title: title,
artist: artist,
description: description,
price: price
});
}
});

当我尝试调用该方法时,应用程序崩溃并引用以下代码行:

Meteor.call("addProject", "http://mybuzzblog.com/wp-content/uploads/2014/12/German-Shepherds.jpg", "Dog 3", "Me", "happy dog", "$60");

这是控制台显示的内容。

W20150729-12:26:31.609(-4)? (STDERR)
W20150729-12:26:31.610(-4)? (STDERR) C:\Users\Raj\AppData\Local\.meteor\packages
\meteor-tool\1.1.3\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\fiber
s\future.js:245
W20150729-12:26:31.610(-4)? (STDERR)
throw(ex);
W20150729-12:26:31.610(-4)? (STDERR)
^
W20150729-12:26:31.610(-4)? (STDERR) Error: Method not found [404]
W20150729-12:26:31.610(-4)? (STDERR) at [object Object]._.extend.apply (pack
ages/ddp/livedata_server.js:1502:1)
W20150729-12:26:31.613(-4)? (STDERR) at [object Object]._.extend.call (packa
ges/ddp/livedata_server.js:1472:1)
W20150729-12:26:31.613(-4)? (STDERR) at app\art.js:5:8
W20150729-12:26:31.613(-4)? (STDERR) at app\art.js:137:3
W20150729-12:26:31.613(-4)? (STDERR) at C:\Users\Raj\art\.meteor\local\build
\programs\server\boot.js:222:10
W20150729-12:26:31.614(-4)? (STDERR) at Array.forEach (native)
W20150729-12:26:31.614(-4)? (STDERR) at Function._.each._.forEach (C:\Users\
Raj\AppData\Local\.meteor\packages\meteor-tool\1.1.3\mt-os.windows.x86_32\dev_bu
ndle\server-lib\node_modules\underscore\underscore.js:79:11)
W20150729-12:26:31.614(-4)? (STDERR) at C:\Users\Raj\art\.meteor\local\build
\programs\server\boot.js:117:5
=> Exited with code: 8
=> Your application is crashing. Waiting for file change.

我可以做什么来解决这个问题?

最佳答案

确保您的 Meteor.methods 位于服务器文件夹下或在 Meteor.isServer 条件中。

关于javascript - Meteor 应用程序在调用方法时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31706135/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com