UNPKG

simplerestapi

Version:

A simple and simplified request generator.

42 lines (40 loc) 902 B
const axios = require('axios'); const petitionType = (api,method,data) => { const options = { method: `${method}`, url: `${api}`, headers: { 'Content-Type': 'application/json', }, "data":data }; axios.request(options) .then((response) => { console.log('Response:', response.data); }) .catch((error) => { console.error('Error:', error.message); }); } const petitionTypeAuth = (api,method,data,auth) => { const options = { method: `${method}`, url: `${api}`, headers: { 'Content-Type': "application/js", 'Authorization': `${auth}` }, "data":data }; axios.request(options) .then((response) => { console.log('Response:', response.data); }) .catch((error) => { console.error('Error:', error.message); }); } module.exports = { petitionType, petitionTypeAuth }