mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
Adding support for node
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
var axios = require('../index');
|
||||
|
||||
var URL = 'http://127.0.0.1:3000/api';
|
||||
var BODY = {
|
||||
foo: 'bar',
|
||||
baz: 1234
|
||||
};
|
||||
|
||||
function handleSuccess(data) { console.log(data); }
|
||||
function handleFailure(data) { console.log('error', data); }
|
||||
|
||||
// GET
|
||||
axios.get(URL, { params: BODY })
|
||||
.then(handleSuccess)
|
||||
.catch(handleFailure);
|
||||
|
||||
// POST
|
||||
axios.post(URL, BODY)
|
||||
.then(handleSuccess)
|
||||
.catch(handleFailure);
|
||||
Reference in New Issue
Block a user