const got = require('got')
const { Response } = require('./response.js')

/**
 * 
 * @param {String} method GET POST DELETE
 * @param {String} url full target url
 * @param {Object} params Raw object of params to send
 * 
 * @returns Response
 */
exports.Request = async function (method, url, params) {
    try {
        const result = await got(url, {json: params, method: method})
        return new Response(result.statusCode, result.body, null)
    } catch(err) {
        return new Response(null, null, err)
    }
}