npm i @splitscript.js/https
// commonjs
const https = require('@splitscript.js/https');
// esm
import https from '@splitscript.js/core'
await https.request(url: string, options: Request)
// Send a GET request to https://httpbin.org/anything?hello="world"
const request = await https.request('https://httpbin.org/anything');
console.log(request.res)
// A https.IncomingMessage
console.log(request.data)
/*
{
args: { hello: '"world"' },
data: '',
files: {},
form: {},
headers: {
Host: 'httpbin.org'
},
json: null,
method: 'GET',
origin: '***.**.***.**',
url: 'https://httpbin.org/anything'
}
*/
await https.request('https://example.com', {body: 'this is a body!'})
// send a request to 'https://example.com?hello=world
await https.request('https://example.com', { params: { hello: 'world' } })
send a request with a method
await https.request('https://example.com', { method: 'POST' })
await https.get('https://example.com')
await https.post('https://example.com')
await https.put('https://example.com')
await https.patch('https://example.com')
await https.delete('https://example.com')