This version of Astro is only compatible with Xcode 7.3
Menu

Request

The Request class is a light wrapper around XMLHttpRequest which allows you to easily make GET or POST requests. By default the Content-Type is JSON but this can be overridden. Each method returns a promise which resolves to the exact response passed to the XHR load event.

Methods

get(url, options) #

Make a GET request to the specified URL.

Options has the following format

{
    headers: {
        Content-Type: 'application/json'
    },
    query: {
        hello: 'world',
        foo: 'bar'
    }
}

Example

Request.get('https://app.mobify.com/api/users', {
    query: {
        sort: 'age'
    }
}).then(function(response) {
        console.log(response);
    }
);

post(url, body, options) #

Make a POST request to the specified URL

Example

Request.post('https://app.mobify.com/api/product', {
    foo: 'bar'
}, {
    headers: {
        Authentication: 'Bearer 1234567890'
    }
}).then(function(response) {
    console.log(response);
});