-
Notifications
You must be signed in to change notification settings - Fork 373
Closed
Labels
codegenconfigThis issue could possibly be solved by adding a config optionThis issue could possibly be solved by adding a config optionfeatureFeature requestFeature request
Description
Is your feature request related to a problem? Please describe.
No problem, just updating code.
Describe the solution you'd like
I would like to convert functions to use async/await functions.
Example existing code output for nodejs-axios:
const axios = require('axios');
let data = JSON.stringify({"field":"value"});
let config = {
method: 'post',
url: 'https://example.com/api/v1/endpoint',
headers: {
'Authorization': 'Bearer auth_token',
'Content-Type': 'application/json'
},
data : data
};
axios(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});Proposed output:
const axios = require('axios');
let data = JSON.stringify({"field":"value"});
const config = {
method: 'post',
url: 'https://example.com/api/v1/endpoint',
headers: {
'Authorization': 'Bearer auth_token',
'Content-Type': 'application/json'
},
data: data
};
async function makeCall(config){
try {
const response = await axios(config);
console.log(JSON.stringify(response.data));
} catch (error) {
console.log(error);
}
}
makeCall(config);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
codegenconfigThis issue could possibly be solved by adding a config optionThis issue could possibly be solved by adding a config optionfeatureFeature requestFeature request