2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-15 11:59:42 +03:00
Files
axios/sandbox/client.js
T
Shin'ya Ueoka 4719d7c219 chore(docs): fix contribution guide (#5935)
chore(docs): fix contribution guide (#5935)
2025-01-30 21:09:12 +02:00

21 lines
401 B
JavaScript

import axios from '../index.js';
const URL = 'http://127.0.0.1:3000/api';
const 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);