const got = require('got') const token = require('basic-auth-token'); module.exports = { postRequest: async (body, url) => { const authToken = token(process.env.username, process.env.password) const options = { method: 'POST', json: JSON.parse(body), headers: { "User-Agent-Wiser": "iPhoneTestTool;iOS6;WiserApp2.0.0", "Authorization": "Basic " + authToken } } try { const response = await got('https://public.wcs.schneider-electric.ws/rpc/public_genie/' + url, options); const res = JSON.parse(response.body) return res } catch (error) { console.log(error.response.body); } } }