Vanilla JS library for a HTTP Requests
Go to file
Dita Aji Pratama a6bea55189 First commit
2023-12-27 23:55:31 +07:00
carrack.js First commit 2023-12-27 23:55:31 +07:00
LICENSE Initial commit 2023-12-27 23:01:22 +07:00
README.md First commit 2023-12-27 23:55:31 +07:00

CarrackJS

JS library for a HTTP Requests

usage

Example usage with JSON data:

var apiUrlJson = "https://example.com/api/json";
var requestDataJson = {
	key1: "value1",
	key2: "value2"
};

sendHttpRequest(apiUrlJson, "POST", requestDataJson, function (error, response) {
	if (error) {
	    console.error("Error:", error);
	}
	else {
	    console.log("JSON Response:", response);
	}
}, "application/json");

Example usage with non-JSON data (e.g., form data):

var apiUrlFormData = "https://example.com/api/formdata";
var formData = new FormData();
formData.append("key1", "value1");
formData.append("key2", "value2");

sendHttpRequest(apiUrlFormData, "POST", formData, function (error, response) {
	if (error) {
	    console.error("Error:", error);
	}
	else {
		console.log("Form Data Response:", response);
	}
}, "multipart/form-data");