Module: ajax

Source:

Methods


<inner> createInstance( [options])

create a unique axios instance based on the options passed

Parameters:
Name Type Argument Default Description
options Object <optional>
{}

axios options to pass to the instance when created

Source:
Returns:
Type
AxiosInstance
Example
import {
 createInstance
} from 'arco';

const ajaxInstance = createInstance({
 baseURL: 'http://foo.com'
});

<inner> del(url [, config])

perform DELETE call via AJAX

Parameters:
Name Type Argument Description
url string

URL to submit DELETE to

config Object <optional>

custom configuration options for specific call

Source:
Returns:
Type
Promise
Example
import {
 del
} from 'arco';

const response = del('/foo/1234');

<inner> get(url [, config])

perform GET call via AJAX

Parameters:
Name Type Argument Description
url string

URL to submit GET to

config Object <optional>

custom configuration options for specific call

Source:
Returns:
Type
Promise
Example
import {
 get
} from 'arco';

const response = get('/foo/1234');

<inner> head(url [, config])

perform HEAD call via AJAX

Parameters:
Name Type Argument Description
url string

URL to submit HEAD to

config Object <optional>

custom configuration options for specific call

Source:
Returns:
Type
Promise
Example
import {
 head
} from 'arco';

const response = head('/foo');

<inner> patch(url [, data] [, config])

perform PATCH call via AJAX

Parameters:
Name Type Argument Description
url string

URL to submit PATCH to

data Object <optional>

data to include in the request body on the call

config Object <optional>

custom configuration options for specific call

Source:
Returns:
Type
Promise
Example
import {
 patch
} from 'arco';

const response = patch('/foo/123');

<inner> post(url [, data] [, config])

perform POST call via AJAX

Parameters:
Name Type Argument Description
url string

URL to submit POST to

data Object <optional>

data to include in the request body on the call

config Object <optional>

custom configuration options for specific call

Source:
Returns:
Type
Promise
Example
import {
 post
} from 'arco';

const response = post('/foo/123', {
 bar: 'baz'
});

<inner> put(url [, data] [, config])

perform PUT call via AJAX

Parameters:
Name Type Argument Description
url string

URL to submit PUT to

data Object <optional>

data to include in the request body on the call

config Object <optional>

custom configuration options for specific call

Source:
Returns:
Type
Promise
Example
import {
 put
} from 'arco';

const response = put('/foo/123', {
 bar: 'foo'
});

<inner> setDefaults( [options])

set the defaults for the axios instance

Parameters:
Name Type Argument Default Description
options Object <optional>
{}
Properties
Name Type Argument Description
baseURL string <optional>

base URL for all axios calls

headers Object <optional>

headers to add to all axios calls

Source:
Returns:
Type
Axios
Example
import {
 setDefaults
} from 'arco';

setDefaults({
 baseURL: 'http://foo.com',
 headers: {
   'X-API-Key': 'bar'
 }
});