Fusio

API / http.request

Sends a HTTP request and return the response

Arguments
Name Type Description
method string A valid HTTP method
url string An absolute url
headers object Optional request headers
body string Optional the request body
Return
Type Description
http_response The HTTP response object
Example
// execute another action and set the response
var http = connector.get("http-connection");
var resp = http.request("GET", "http://localhost/acme/api");

if (resp.getStatusCode() === 200) {
  var data = JSON.parse(resp.getBody());

  response.setBody(data);
} else {
  response.setBody({
    success: false,
    message: "The request was not successful"
  });
}