Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Section


Column
width25%

Parameters

  • Object options/String requestType
    If you pass a string, you can pass the request type (get, post). If you pass an object, it will be passed into the request module API (see module API options). If an object is passed, you do not need to pass any other parameters.
  • String URL
    The endpoint to your web service.
  • String|Object Body (optional)
    The body of the request. If you pass in an object, it will send the request in JSON and it will also return JSON. Otherwise, it will pass as text and return a String.


Column
width25%

Return Value

Object / String String The response body.



Exception Handling

This API will crash if any HTTP code is returnedthrow an exception if the HTTP request couldn't be completed (such as for a networking problem), or if the HTTP request completes with a status code other than 200.


Examples

Code Block
languagejavascript
titleExample of General Use
//Simple
var result = pjs.sendRequest("post", "http://website.com/myJSONAPI", {key: 'value'});
 
//Advanced, using request API options
result = pjs.sendRequest({
      method: "POST",
      uri: "http://website.com/myJSONAPI",
      body: {key: 'value'},
      json: true,
	  timeout: 5000,
      time: true
});

...