Moralis.Cloud.httpRequest
. It allows you to send HTTP requests to any HTTP server. This function takes an options object to configure the call.Moralis.Cloud.httpRequest
returns a promise that will be resolved on a successful HTTP status code; otherwise, the promise will be rejected. In the above example, we use then()
to handle both outcomes.Moralis.Cloud.httpRequest
does not follow redirects caused by HTTP 3xx response codes, the followRedirects: true
option can be used as shown here: Following Redirectsโparams
on the options object. You can either pass a JSON object of key-value pairs such as:String
like this:header
attribute of the options object. Letโs say you want to set the Content-Type of the request, you can do:method
attribute of the options object. The body of the POST can be set using the body
. A simple example would be:http://www.example.com/create_post
with body that is the URL form encoded body
attribute. If you want the body to be JSON encoded, you can instead do this:Moralis.Cloud.httpRequest
does not follow redirects caused by HTTP 3xx response codes. You can use the followRedirects
option to change this behavior to follow redirects:success
and error
will contain:status
- The HTTP Response status.headers
- The response headers.buffer
- The raw byte representation of the response body.text
- The raw response body.data
- The parsed response, if Cloud Code knows how to parse the content-type that was sent.cookies
- The cookies sent by the server.