First release of Fetch for Arduino.
This release implements the basic functionalities that can be found in the Javascript fetch API.
You can make GET and POST request to any HTTP and HTTPS server. In case of HTTPS server, you need to provide the server's SHA1 fingerprint which you can find by opening the webpage in browser, clicking on the greenlock, and going into the certificate details.
In Javascript, fetch API works like:
const response = await fetch("https://api.grandeur.tech/", {
method: "GET"
});
console.log(response);
In Arduino, you can do this:
RequestOptions options;
options.method = "GET";
Response response = fetch("https://api.grandeur.tech/", options);
Serial.println(response);
You can also provide your headers to the request like this:
options.headers.contentType = "application/json";
You can also provide your body to the request like this:
options.body = "{\"email\": \"EMAIL\"}";
The response
object gives you the following data:
response.status = 200;
response.statusText = "OK";
You can also get response headers like this:
response.headers.get("Content-Type");