Emmanuel Amodu Emmanuel Amodu - 18 days ago 4x
HTTP Question

Having issues getting page title from html with meteor.http package

Meteor.http.call( 'GET', 'http://google.com', {}, function( error, response ) {
if ( error ) {
console.log( error );
} else {
console.log( response );

the problem is it keeps showing this error this is my first time using this package so am not sure if i really understand it.

this is the error on my console.

XMLHttpRequest cannot load http://google.com. No
'Access-Control-Allow-Origin' header is present on the requested
resource. Origin 'http://localhost:3000' is therefore not allowed


HTTP Requests from the browser will always run into this CORS issue unless you specifically allow them with CORS headers.

Meteor has a good way of dealing with it. First up you do a call:


In the server you write a Meteor method like this

    httpRequest: function(url,params) {
    // Send the http request here

You cannot do a call back to the client with the result of the http request, but you can put it into a database record, which the client subscribes to.