109 {
110 FL_WARN(
"APPROACH 1: Promise-based pattern with explicit types");
111
112
113
114
115
116
118
120 FL_WARN(
"SUCCESS [Promise] HTTP fetch successful! Status: "
122
123
124
127 FL_WARN(
"CONTENT [Promise] Content-Type: " << *content_type);
128 }
129
130
132 if (response_body.
length() >= 100) {
133 FL_WARN(
"RESPONSE [Promise] First 100 characters: " << response_body.
substr(0, 100));
134 } else {
135 FL_WARN(
"RESPONSE [Promise] Full response (" << response_body.
length()
136 << " chars): " << response_body);
137 }
138
139
141 } else {
142
143 FL_WARN(
"ERROR [Promise] HTTP Error! Status: "
146
147
149 }
150 })
151
152
153 .catch_([](
const fl::Error& network_error) {
154
155 FL_WARN(
"ERROR [Promise] Network Error: " << network_error.
message);
156
157
159 });
160}
StrN substr(fl::size start, fl::size length) const
fl::optional< fl::string > get_content_type() const
Get content type convenience method.
const fl::string & status_text() const
HTTP status text (like JavaScript response.statusText)
int status() const
HTTP status code (like JavaScript response.status)
bool ok() const
Check if response is successful (like JavaScript response.ok)
const fl::string & text() const
Response body as text (like JavaScript response.text())
HTTP response class (unified interface)
void fill_solid(struct CRGB *targetArray, int numToFill, const struct CRGB &color)
Fill a range of LEDs with a solid color.
fl::promise< response > fetch_get(const fl::string &url, const fetch_options &request)
HTTP GET request.
Representation of an RGB pixel (Red, Green, Blue)