1const headers = {
2 'Content-Type': 'application/json',
3 'Authorization': 'JWT fefege...'
4}
5
6axios.post(Helper.getUserAPI(), data, {
7 headers: headers
8 })
9 .then((response) => {
10 dispatch({
11 type: FOUND_USER,
12 data: response.data[0]
13 })
14 })
15 .catch((error) => {
16 dispatch({
17 type: ERROR_FINDING_USER
18 })
19 })
1axios.post('url', {"body":data}, {
2 headers: {
3 'Content-Type': 'application/json'
4 }
5 }
6)
1// Send a POST request
2axios({
3 method: 'post',
4 url: '/user/12345',
5 data: {
6 firstName: 'Fred',
7 lastName: 'Flintstone'
8 },
9 headers: {'Authorization': 'Bearer ...'}
10});
1let auth = ``; //auth key
2let url = ``; //api url
3
4const axios = require(`axios`);
5axios({
6 method: 'get',
7 url: url,
8 headers: {
9 "Authorization": auth
10 },
11}).then(function (res) {
12 console.log(res.data)
13});
1const username = ''
2const password = ''
3
4const token = Buffer.from(`${username}:${password}`, 'utf8').toString('base64')
5
6const url = 'https://...'
7
8axios.post(url, {
9 headers: {
10 'Authorization': `Basic ${token}`
11 }
12})
13
1var postData = {
2 email: "test@test.com",
3 password: "password"
4};
5
6let axiosConfig = {
7 headers: {
8 'Content-Type': 'application/json;charset=UTF-8',
9 "Access-Control-Allow-Origin": "*",
10 }
11};
12
13axios.post('http://<host>:<port>/<path>', postData, axiosConfig)
14.then((res) => {
15 console.log("RESPONSE RECEIVED: ", res);
16})
17.catch((err) => {
18 console.log("AXIOS ERROR: ", err);
19})