1axios({
2 method: 'post',
3 url: 'myurl',
4 data: bodyFormData,
5 headers: {'Content-Type': 'multipart/form-data' }
6 })
7 .then(function (response) {
8 //handle success
9 console.log(response);
10 })
11 .catch(function (response) {
12 //handle error
13 console.log(response);
14 });
1var bodyFormData = new FormData();
2
3bodyFormData.append('userName', 'Fred');
4bodyFormData.append('image', imageFile);
5
6axios({
7 method: "post",
8 url: "myurl",
9 data: bodyFormData,
10 headers: { "Content-Type": "multipart/form-data" },
11})
12 .then(function (response) {
13 //handle success
14 console.log(response);
15 })
16 .catch(function (response) {
17 //handle error
18 console.log(response);
19 });
1var body = {
2 userName: 'Fred',
3 userEmail: 'Flintstone@gmail.com'
4}
5
6axios({
7 method: 'post',
8 url: '/addUser',
9 data: body
10})
11.then(function (response) {
12 console.log(response);
13})
14.catch(function (error) {
15 console.log(error);
16});
17
1//assuming instance is your axios instance.
2
3instance.get("/test",{params:{key:value, key1:value1}}).then((data)=>{}).catch((error)=>{})
4
5//this will send a GET request to /test?key=value&key1=value1
6
7