Search…
HTTP Module
Basic http(s) callout capability. Import
1
import http from 'http';
Copied!

Methods

get/head/post/put/patch/delete(url, options)

Arguments
  • url (String) endpoint url
  • options
    • buffer (Boolean:false) If true, the result body is a Buffer object. Otherwise, the result body is a utf-8 encoded string.
    • timeout (Number) timeout in milliseconds.
    • strictSSL (Boolean:false) Only available in the development environment.
    • headers (Object) custom headers.
    • body (String) for POST, PUT, and PATCH only. Must be a string.
    • sslOptions
      • pfx
      • key
      • cert
      • ca
      • passphrase
      • ciphers
      • rejectUnauthorized
      • servername
      • secureProtocol
      • minDHSize
Returns
Object
  • headers (Object) an object containing response headers
  • body (String) the response body.
  • statusCode (Number) http status code.
  • statusMessage (String) http status message.

getCiphers()

Returns
Returns the list of available ciphersHTTP Example
1
import http from 'http'
2
import xml from 'xml'
3
import request from 'request'
4
import response from 'response'
5
6
let data = http.get('http://www.xmlfiles.com/examples/simple.xml', {headers: {accept: 'text/xml'}}).body
7
8
if (request.getHeader('Accept') == 'text/xml') {
9
response.setHeader('Content-Type', 'text/xml')
10
response.write(data)
11
return
12
}
13
14
return xml.toJs(data)
Copied!
Last modified 2mo ago