// Create an instance
var api = new APIConnect();
// Set the domain
api.domain('search.twitter.com');
// Create an instance
var api = new APIConnect();
// Set the domain
api.domain('search.twitter.com');
// Connect the route
api.connect('search');
// Create an instance
var api = new APIConnect();
// Set the domain
api.domain('search.twitter.com');
// With a format
api.connect('search.json');
// Create an instance
var api = new APIConnect();
// Set the domain
api.domain('search.twitter.com');
// With a format
api.connect('search.json');
// Run the route
api.getSearch();
// Create an instance
var api = new APIConnect();
// Set the domain
api.domain('search.twitter.com');
// With a format
api.connect('search.json');
// Run the route
api.getSearch({ q: 'cookpad' }); // With params
// Create an instance
var api = new APIConnect();
// Set the domain
api.domain('search.twitter.com');
// With a format
api.connect('search.json');
// Run the route
api.getSearch({ q: 'cookpad' }, { success: showResults }); // And a callback
// Create an instance
var api = new APIConnect();
// Set the domain
api.domain('search.twitter.com');
// With a format
api.connect('search.json');
// Twitter only supports JSONP
api.cors(false);
// And a callback
api.getSearch({ q: 'cookpad' }, { success: showResults });
// Create an instance
var api = new APIConnect();
// Set the domain
api.domain('search.twitter.com');
// With a format
api.connect('search.json');
// Twitter only supports JSONP
api.cors(false);
// Here we go!
api.getSearch({ q: 'cookpad' }, {
success: showResults
});
// Create an instance
var api = new APIConnect();
// Set the domain
api.domain('search.twitter.com');
// With a format
api.connect('search.json');
// Twitter only supports JSONP
api.cors(false);
// Here we go!
api.getSearch({ q: 'cookpad' }, {
success: showResults,
// All options are handed to $.ajax
complete: function() {
alert('Done!');
}
});
// Round 2
// Round 2
// Create the instance
var api = new APIConnect();
// Round 2
// Create the instance
var api = new APIConnect();
// Set the domain
api.domain('api.iknow.jp');
// Round 2
// Create the instance
var api = new APIConnect();
// Set the domain
api.domain('api.iknow.jp');
// Turn off cors
api.cors(false);
// Round 2
// Create the instance
var api = new APIConnect();
// Set the domain
api.domain('api.iknow.jp');
// Turn off cors
api.cors(false);
// Connect the route with optional context
api.connect('goals/:goal_id/items.json');
// Round 2
// Create the instance
var api = new APIConnect();
// Set the domain
api.domain('api.iknow.jp');
// Turn off cors
api.cors(false);
// Connect the route with optional context
api.connect('goals/:goal_id/items.json');
// Run the route!
api.getItems({ goal_id: 910 }).then(showItems);
var api = new APIConnect();
api.domain('api.twitter.com');
// Alternate HTTP methods
api.connect('POST :username/favorites');
api.createFavorites({ username: 'budday' });
var api = new APIConnect();
api.domain('api.twitter.com');
// RESTful resources
api.resource(':username/favorite');
api.getFavorite({ username: 'budday' });
api.createFavorite({ username: 'budday' });
api.updateFavorite({ username: 'budday' });
api.destroyFavorite({ username: 'budday' });
var api = new APIConnect();
api.domain('api.twitter.com');
// "favorites" indicates a collection
api.resource(':username/favorites');
// index
api.getFavorites({ username: 'budday' });
// show
api.getFavorite({ username: 'budday', id: 3 });
api.createFavorite({ username: 'budday' });
api.updateFavorite({ username: 'budday', id: 3 });
api.destroyFavorite({ username: 'budday', id: 3 });
var api = new APIConnect();
api.domain('andrewplummer.com');
api.connect('recipes');
// Allow credentials
api.getRecipes({}).then(showResults);
api = api || new APIConnect();
api.domain('andrewplummer.com');
api.connect('recipes');
// Internal caching
api.getRecipes({}, { cache: true }).then(showResults);
// All routes/options/params in the constructor
var api = new APIConnect({
domain : 'api.twitter.com',
protocol : 'https',
cors : false,
routes : [
'GET /status',
'POST /statuses/update',
'POST direct_messages/destroy/:id AS destroyMessage'
]
});
api.destroyMessage({ id: 7 });
// Future??
var api = new APIConnect();
api.getManifest(function() {
api.getUserTweets();
// ...
});