English 中文(简体)
How easy to call external Web APIs in Meteor?
原标题:

Does (or will) Meteor provide a library to handle external Web API calls? E.g. to build a Meteor app that integrates with Facebook Graph API or Google Spreadsheet API.

问题回答

Meteor now includes the http package. First, run meteor add http. Then you can make HTTP requests on the server in either sync or async style:

// server sync
res = Meteor.http.get(SOME_URL);
console.log(res.statusCode, res.data);

// server async
Meteor.http.get(SOME_URL, function (err, res) {
  console.log(res.statusCode, res.data);
});

Same thing works on the client, but you have to use the async form.

if (Meteor.is_server) {
    var http = __meteor_bootstrap__.require("http")
    // talk to external HTTP API like you would in node.js
}

HTTP

HTTP provides an HTTP request API on the client and server. To use these functions, add the HTTP package to your project with $ meteor add http.





相关问题
Download file using Web API call

I am using Web API to download a file. Let me first preface that this is new territory for me. My download function inside the Web API code will initiate a download if I go directly to the API s ...

Indian Railway Train Search API [closed]

Is there any API provided by Indian Railways to search its train network, time-tables etc. There are many sites out there which show time-table etc. I searched Google but couldn t find any info on Web ...

Freely Available Web Services/APIs [closed]

I m building some Silverlight applications in my spare time, and I wanted find some freely available web services or APIs that I can call. Any suggestions?

What s the simplest way to do authentication with a web API?

I ve got a web API that provides data to users without authentication (the website lets users post data, after they ve logged in using traditional cookies & sessions). Someone wants to develop an ...

ISBN -> bookdata Lookup to fill in a database

Ok, I wanting to database a small library. I ve only had limited experience with databases, and none with querying from a webserver. I m going to want to retrieve information like title, Publisher, ...

Does IMDB provide an API? [closed]

I recently found a movie organizer application which fetches its data from the IMDB database. Does IMDB provide an API for this, or any third party APIs available?

Google Alerts web API for Python?

Google web APIs have a Python library. Google Alerts has an email and an RSS feed. Does anyone know of an automated way to add Google Alerts through a web API in Python? That is, without clicking. ...

Finding Websites From Company Name

I ve got a list of 6,000 company names (along with their headquarters address) and I need to find the web address for each of them. I m considering using the Google Web API (obviously this will take a ...

热门标签