version 3.0.0 API Docs (#4943)

* Adds documentation and docs generation upon merge

* nits
This commit is contained in:
Florent Vilmart
2018-08-09 16:20:13 -04:00
parent 457d51a972
commit 0571675fcd
10 changed files with 465 additions and 3 deletions

View File

@@ -33,6 +33,31 @@ var encodeBody = function({body, headers = {}}) {
return {body, headers};
}
/**
* Makes an HTTP Request.
*
* **Available in Cloud Code only.**
*
* By default, Parse.Cloud.httpRequest does not follow redirects caused by HTTP 3xx response codes. You can use the followRedirects option in the {@link Parse.Cloud.HTTPOptions} object to change this behavior.
*
* Sample request:
* ```
* Parse.Cloud.httpRequest({
* url: 'http://www.parse.com/'
* }).then(function(httpResponse) {
* // success
* console.log(httpResponse.text);
* },function(httpResponse) {
* // error
* console.error('Request failed with response code ' + httpResponse.status);
* });
* ```
*
* @method httpRequest
* @name Parse.Cloud.httpRequest
* @param {Parse.Cloud.HTTPOptions} options The Parse.Cloud.HTTPOptions object that makes the request.
* @return {Promise<Parse.Cloud.HTTPResponse>} A promise that will be resolved with a {@link Parse.Cloud.HTTPResponse} object when the request completes.
*/
module.exports = function(options) {
var callbacks = {
success: options.success,
@@ -78,4 +103,16 @@ module.exports = function(options) {
});
};
/**
* @typedef Parse.Cloud.HTTPOptions
* @property {String|Object} body The body of the request. If it is a JSON object, then the Content-Type set in the headers must be application/x-www-form-urlencoded or application/json. You can also set this to a {@link Buffer} object to send raw bytes. If you use a Buffer, you should also set the Content-Type header explicitly to describe what these bytes represent.
* @property {function} error The function that is called when the request fails. It will be passed a Parse.Cloud.HTTPResponse object.
* @property {Boolean} followRedirects Whether to follow redirects caused by HTTP 3xx responses. Defaults to false.
* @property {Object} headers The headers for the request.
* @property {String} method The method of the request. GET, POST, PUT, DELETE, HEAD, and OPTIONS are supported. Will default to GET if not specified.
* @property {String|Object} params The query portion of the url. You can pass a JSON object of key value pairs like params: {q : 'Sean Plott'} or a raw string like params:q=Sean Plott.
* @property {function} success The function that is called when the request successfully completes. It will be passed a Parse.Cloud.HTTPResponse object.
* @property {string} url The url to send the request to.
*/
module.exports.encodeBody = encodeBody;