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.httpRequestreturns 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.
paramson the options object. You can either pass a JSON object of key-value pairs such as:
headerattribute of the options object. Let’s say you want to set the Content-Type of the request, you can do:
methodattribute 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_postwith body that is the URL form encoded
bodyattribute. If you want the body to be JSON encoded, you can instead do this:
Moralis.Cloud.httpRequestdoes not follow redirects caused by HTTP 3xx response codes. You can use the
followRedirectsoption to change this behavior to follow redirects:
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.