HTTP Post Request Help

Hi,

I’m trying to do an HTTP Post Request. I usually do this using ajax by:

var formData = new FormData();
formData.append("key1", "value1");
$.ajax({
	type : "POST",
	url : "https://myurlhere.com/api/myphp.php",
	dataType: "text",
	cache: false,
	contentType: false,
	processData: false,
	data: formData,
	success: function(result) {
		console.log(result);
	}
});

How do I translate this ajax code to pc.http (passing with settings and data)

pc.http.post("https://myurlhere.com/api/myphp.php", function(err, result) {
    console.log(result);
});

Hi @rumblerock,

You can check the docs on the exact options available for the post request here:

https://developer.playcanvas.com/en/api/pc.Http.html#post

The only thing I am not sure if it’s supported is passing a FormData instance, instead of a raw object. Feel free to try if that works out for you.