@@ -168,7 +168,7 @@ const serverHost = "127.0.0.1";
168
168
const serverPort = " 5051" ;
169
169
170
170
async function start () {
171
- const server = new DaprServer (serverHost, serverPort, daprHost, daprPort);;
171
+ const server = new DaprServer (serverHost, serverPort, daprHost, daprPort);
172
172
173
173
const bindingName = " my-binding-name" ;
174
174
@@ -185,6 +185,55 @@ start().catch((e) => {
185
185
186
186
> For a full guide on output bindings visit [ How-To: Use bindings] ({{< ref howto-bindings.md >}}).
187
187
188
+ ### Configuration API
189
+
190
+ > 💡 The configuration API is currently only available through gRPC
191
+
192
+ #### Getting a configuration value
193
+
194
+ ``` javascript
195
+ import { DaprServer } from " dapr-client" ;
196
+
197
+ const daprHost = " 127.0.0.1" ;
198
+ const daprPort = " 3500" ;
199
+ const serverHost = " 127.0.0.1" ;
200
+ const serverPort = " 5051" ;
201
+
202
+ async function start () {
203
+ const client = new DaprClient (daprHost, daprPort, CommunicationProtocolEnum .GRPC );
204
+ const config = await client .configuration .get (" config-redis" , [" myconfigkey1" , " myconfigkey2" ]);
205
+ }
206
+
207
+ start ().catch ((e ) => {
208
+ console .error (e);
209
+ process .exit (1 );
210
+ });
211
+ ```
212
+
213
+ #### Subscribing to Key Changes
214
+
215
+ ``` javascript
216
+ import { DaprServer } from " dapr-client" ;
217
+
218
+ const daprHost = " 127.0.0.1" ;
219
+ const daprPort = " 3500" ;
220
+ const serverHost = " 127.0.0.1" ;
221
+ const serverPort = " 5051" ;
222
+
223
+ async function start () {
224
+ const client = new DaprClient (daprHost, daprPort, CommunicationProtocolEnum .GRPC );
225
+ await client .configuration .subscribeWithKeys (" config-redis" , [" myconfigkey1" , " myconfigkey2" ], () => {
226
+ // Received a key update
227
+ });
228
+ }
229
+
230
+ start ().catch ((e ) => {
231
+ console .error (e);
232
+ process .exit (1 );
233
+ });
234
+ ```
235
+
236
+
188
237
## Related links
189
238
190
239
- [ JavaScript SDK examples] ( https://github.com/dapr/js-sdk/tree/master/examples )
0 commit comments