{"action":"created","issue":{"url":"https://api.github.com/repos/jrudio/meteor-bluebird/issues/1","labels_url":"https://api.github.com/repos/jrudio/meteor-bluebird/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/jrudio/meteor-bluebird/issues/1/comments","events_url":"https://api.github.com/repos/jrudio/meteor-bluebird/issues/1/events","html_url":"https://github.com/jrudio/meteor-bluebird/issues/1","id":108130560,"number":1,"title":"Suggestion: include a couple of examples?","user":{"login":"JulianKingman","id":1566400,"avatar_url":"https://avatars.githubusercontent.com/u/1566400?v=3","gravatar_id":"","url":"https://api.github.com/users/JulianKingman","html_url":"https://github.com/JulianKingman","followers_url":"https://api.github.com/users/JulianKingman/followers","following_url":"https://api.github.com/users/JulianKingman/following{/other_user}","gists_url":"https://api.github.com/users/JulianKingman/gists{/gist_id}","starred_url":"https://api.github.com/users/JulianKingman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JulianKingman/subscriptions","organizations_url":"https://api.github.com/users/JulianKingman/orgs","repos_url":"https://api.github.com/users/JulianKingman/repos","events_url":"https://api.github.com/users/JulianKingman/events{/privacy}","received_events_url":"https://api.github.com/users/JulianKingman/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jrudio/meteor-bluebird/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-09-24T13:32:59Z","updated_at":"2015-09-27T00:31:19Z","closed_at":null,"body":"Hi @jrudio,\r\n\r\nI was hoping you could post a couple of examples to the documentation on how to use this. I'm having trouble implementing this into a method (I get this error from the client-side: \"Can't make a blocking HTTP call from the client; callback required.\"). I'm wrapping my method in 'Meteor.isServer', but can't tell if I'm doing it right."},"comment":{"url":"https://api.github.com/repos/jrudio/meteor-bluebird/issues/comments/143506984","html_url":"https://github.com/jrudio/meteor-bluebird/issues/1#issuecomment-143506984","issue_url":"https://api.github.com/repos/jrudio/meteor-bluebird/issues/1","id":143506984,"user":{"login":"jrudio","id":6628361,"avatar_url":"https://avatars.githubusercontent.com/u/6628361?v=3","gravatar_id":"","url":"https://api.github.com/users/jrudio","html_url":"https://github.com/jrudio","followers_url":"https://api.github.com/users/jrudio/followers","following_url":"https://api.github.com/users/jrudio/following{/other_user}","gists_url":"https://api.github.com/users/jrudio/gists{/gist_id}","starred_url":"https://api.github.com/users/jrudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrudio/subscriptions","organizations_url":"https://api.github.com/users/jrudio/orgs","repos_url":"https://api.github.com/users/jrudio/repos","events_url":"https://api.github.com/users/jrudio/events{/privacy}","received_events_url":"https://api.github.com/users/jrudio/received_events","type":"User","site_admin":false},"created_at":"2015-09-27T00:31:19Z","updated_at":"2015-09-27T00:31:19Z","body":"Yes, your intentions of this function makes sense.\r\n\r\nTwo things:\r\n\r\n- Your Promise needs to call `reject` and / or `resolve` otherwise your `.then()` won't ever execute\r\n- When you return something within a `.then()` it will pass that value into the next `.then()` that you chain\r\n\r\n\r\nSo to address `reject` and `resolve`. In your case you just need to call `resolve` which will allow the Promise to call `.then()`. `reject` will be for error handling, so that is up to you.\r\n\r\nChange the `return`:\r\n\r\n```javascript\r\n                var content = $('html').find(selector).html();\r\n                return content;\r\n```\r\nto\r\n```javascript\r\n                var content = $('html').find(selector).html();\r\n               resolve(content);\r\n```\r\n\r\nFrom the looks of it, you are trying to return the html to the callee of `scrapeUrl()`. That won't work as you cannot return values outside of a promise.\r\n\r\nThere's a couple of things you can do:\r\n\r\nYou can directly use the html within `.then()`\r\n\r\n```javascript\r\n        getText(selector).then(function (html) {\r\n            saveHTML(html);\r\n        }).catch(function (e) {\r\n            console.log('error', e);\r\n        });\r\n```\r\n\r\nI haven't tried this one personally, but I believe you can return the promise without `.then()` and have your callee handle `.then()`\r\n\r\n```javascript\r\nMeteor.call('doStuff', function (promise) {\r\n  promise.then(function (html) {\r\n    saveHTML(html)\r\n  })\r\n    .catch(function (e) {\r\n       console.log(e)\r\n    })\r\n})\r\n```\r\n\r\nLet me know if you something isn't clear, I'll try my best to help!"}}