loading...
Cover image for How to Post data json use apikey

How to Post data json use apikey

anggachelsea profile image Angga Lesmana ・1 min read

I will share to you about my experience although not too much
but i hope this is important for you as javascript developer

const axios = require('axios');
const express = require('express');

const app = express();

var postData = {
'this':'this data will you post'
}

let axiosConfig = {
headers: {
'Authorization': 'Bearer your-apikey',
'Response-Format': 'JSON',
'Content-Type': 'application/json',
"Access-Control-Allow-Origin": "*",
}
};

axios.post('https://link apikey', postData, axiosConfig)
.then((res) => {
console.log(RESPONSE RECEIVED: ${postData}, res);
})
.catch((err) => {
console.log("AXIOS ERROR: ", err);
})

axios.get('https://link apikey')
.then(response => {
console.log(response.data.created_at);
});

try {

} catch (error) {

}

axios.all([
axios.get('https://link apikey'),
axios.get('https://link apikey')
])
.then(axios.spread((user1, user2) => {
console.log('Date created: ', user1.data.created_at);
console.log('Date created: ', user2.data.created_at);
}));

Posted on by:

anggachelsea profile

Angga Lesmana

@anggachelsea

I am a fullstack JavaScript web developer . I glad for coding or programming

Discussion

markdown guide