usage
install
npm i @splitscript.js/httpsimport
// commonjs
const https = require('@splitscript.js/https');
// esm
import https from '@splitscript.js/core'send a request
await https.request(url: string, options: Request)example
// 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'
}
*/send a body
send URL params
send a request with a method
You can specify method in your config like this:
or you can use https.<method> like this:
Last updated
Was this helpful?