-
Notifications
You must be signed in to change notification settings - Fork 85
REST access not working for publications with arguments #157
Comments
Did you try it without the trailing slash? You also don't use the argument as it gets parsed to the Meteor.publish("export", function export(argument_from_url) {...}, {
url: "export/:0",
}) |
Thanks for your suggestion. I also tried without the trailing slash now. When I check And you're right, in the example above I was missing the definition of the argument of the export function. Any other ideas ...? |
I think what is happening is that you use the Did a little test and it works as expected for me. $ meteor add simple:rest // server code
import {Mongo} from 'meteor/mongo';
export const Items = new Mongo.Collection('items');
if (Meteor.isServer) {
// create some items
Meteor.startup(function() {
if (!Items.find().count()) {
Items.insert({ name: "test1" })
Items.insert({ name: "test2" })
Items.insert({ name: "test3" })
}
})
Meteor.publish('items', function items(item_name) {
if (item_name) {
return Items.find({
name: item_name
});
} else {
return Items.find({});
}
}, {
url: "item/:0"
});
} cURL'ing the items like this, with and without slash $ curl localhost:3000/item/test1
{
"items": [
{
"_id": "hkBBrBpn9obntiviG",
"name": "test1"
}
]
} curl localhost:3000/item/test1/
{
"items": [
{
"_id": "hkBBrBpn9obntiviG",
"name": "test1"
}
]
} |
Using the simple:rest package to access publications works very nicely!
However, I didn't manage yet to GET a publication that requires an argument.
http://localhost:3000/publications/export/
, I get an error message (as I check for the argument in my publication)http://localhost:3000/publications/export/12345/
the main app gets loaded instead (well, with some broken links to images)it doesn't help, I still get the main app.
What am I missing?
The text was updated successfully, but these errors were encountered: