This repository has been archived by the owner on Jun 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Http
kmussel edited this page Dec 15, 2010
·
4 revisions
CoreJS offers Http request using an object for handling one Http instance at a time, and offers several global, simplified methods for working with request. CoreJS also offers the ability to have callbacks to make the request asynchronous. To make a request asynchronous you simply add a callback function as the last argument.
Global Methods:
// Making a Post Request:
var content = Http.post("/path/to/file", {firstArgument:"someData", secondArgument:"moreData"});
OR Asynchronously
Http.post("/path/to/file", {arg:"arg1", arg2:"arg2"}, function(data){ print(data); });
// Making a Get Request
Same format as post but use Http.get() instead.
Http Object usage:
Currently the Http object doesn't do anything more than using the global Http object. But in the future this will allow us to keep an instance of it should we choose to add more data that we want to keep a reference to.
// Create a new Http object:
var httpClient = new HttpClient();
//Uses the same format as the global method except instead of Http we use our instance of the class
httpClient.post();
httpClient.get();