@@ -53,47 +53,71 @@ echo '[
53
53
54
54
[source,javascript]
55
55
----
56
- const data = [
57
- { "item": "journal", "qty": 25, "size": { "h": 14, "w": 21, "uom": "cm" }, "status": "A" },
58
- { "item": "notebook", "qty": 50, "size": { "h": 8.5, "w": 11, "uom": "in" }, "status": "A" },
59
- { "item": "paper", "qty": 100, "size": { "h": 8.5, "w": 11, "uom": "in" }, "status": "D" },
60
- { "item": "planner", "qty": 75, "size": { "h": 22.85, "w": 30, "uom": "cm" }, "status": "D" },
61
- { "item": "postcard", "qty": 45, "size": { "h": 10, "w": 15.25, "uom": "cm" }, "status": "A" }
62
- ];
63
-
64
56
// Create collection
65
- fetch('[INSTANCE-URL]/inventory', {
66
- method: 'PUT',
67
- headers: {
68
- 'Authorization': 'Basic [BASIC-AUTH]'
69
- }
70
- })
71
- .then(response => {
72
- if (response.ok) {
73
- console.log('Collection created successfully');
74
- } else {
75
- console.error('Failed to create collection:', response.status);
76
- }
77
- })
78
- .catch(error => console.error('Error:', error));
79
-
80
- // Insert documents
81
- fetch('[INSTANCE-URL]/inventory', {
82
- method: 'POST',
83
- body: JSON.stringify(data),
57
+ fetch("http://localhost:8080/inventory", {
58
+ method: "PUT",
84
59
headers: {
85
- 'Authorization': 'Basic [BASIC-AUTH]',
86
- 'Content-Type': 'application/json'
87
- }
88
- })
89
- .then(response => {
60
+ Authorization: "Basic YWRtaW46c2VjcmV0",
61
+ },
62
+ }).then((response) => {
90
63
if (response.ok) {
91
- console.log('Documents inserted successfully');
64
+ console.log("Collection created successfully");
65
+
66
+ const data = [
67
+ {
68
+ item: "journal",
69
+ qty: 25,
70
+ size: { h: 14, w: 21, uom: "cm" },
71
+ status: "A",
72
+ },
73
+ {
74
+ item: "notebook",
75
+ qty: 50,
76
+ size: { h: 8.5, w: 11, uom: "in" },
77
+ status: "A",
78
+ },
79
+ {
80
+ item: "paper",
81
+ qty: 100,
82
+ size: { h: 8.5, w: 11, uom: "in" },
83
+ status: "D",
84
+ },
85
+ {
86
+ item: "planner",
87
+ qty: 75,
88
+ size: { h: 22.85, w: 30, uom: "cm" },
89
+ status: "D",
90
+ },
91
+ {
92
+ item: "postcard",
93
+ qty: 45,
94
+ size: { h: 10, w: 15.25, uom: "cm" },
95
+ status: "A",
96
+ },
97
+ ];
98
+
99
+ // Insert documents
100
+ fetch("http://localhost:8080/inventory", {
101
+ method: "POST",
102
+ body: JSON.stringify(data),
103
+ headers: {
104
+ Authorization: "Basic YWRtaW46c2VjcmV0",
105
+ "Content-Type": "application/json",
106
+ },
107
+ })
108
+ .then((response) => {
109
+ if (response.ok) {
110
+ console.log("Documents inserted successfully");
111
+ } else {
112
+ console.error("Failed to insert documents:", response.status);
113
+ }
114
+ })
115
+ .catch((error) => console.error("Error:", error));
92
116
} else {
93
- console.error(' Failed to insert documents:' , response.status);
117
+ console.error(" Failed to create collection:" , response.status);
94
118
}
95
119
})
96
- .catch(error => console.error(' Error:' , error));
120
+ .catch(( error) => console.error(" Error:" , error));
97
121
----
98
122
99
123
=== Retrieving documents
0 commit comments