Method for executing an HTTP request. If data type is not specified, it will default to 'text'
.
This function is meant for more advanced usage of HTTP requests in p5.js. It is best used when a Request
object is passed to the path
parameter.
This method is suitable for fetching files up to size of 64MB when "GET" is used.
Examples
Syntax
httpDo(path, [method], [datatype], [data], [callback], [errorCallback])
httpDo(path, [callback], [errorCallback])
Parameters
path
String|Request: name of the file or url to load
method
String: either "GET", "POST", "PUT", "DELETE", or other HTTP request methods
datatype
String: "json", "jsonp", "xml", or "text"
data
Object: param data passed sent with request
callback
Function: function to be executed after httpGet() completes, data is passed in as first argument
errorCallback
Function: function to be executed if there is an error, response is passed in as first argument
Returns
Promise: A promise that resolves with the data when the operation completes successfully or rejects with the error after one occurs.
Notice any errors or typos? Please let us know. Please feel free to edit src/io/files.js and open a pull request!