-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
31 lines (25 loc) · 817 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <nlohmann/json.hpp>
#include "api/api.hpp"
#include "datetime/datetime.hpp"
using t_json = nlohmann::json;
int main() {
utility::string_t apiUrl = U("https://simple-firebase-rest-api.vercel.app/api/documents");
try {
API api(apiUrl);
std::string formattedDateTime = getCurrentDateTimeFormatted();
t_json jsonData = {
{"data", {
{"name", "gabe"},
{"age", 24},
{"createdAt", formattedDateTime}
}}
};
api.post(jsonData);
t_json updatedData = api.get();
std::cout << "Updated Response JSON:\n" << updatedData.dump(4) << std::endl;
} catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
}
return 0;
}