This repository was archived by the owner on May 20, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -116,14 +116,13 @@ import 'dart:convert';
116116
117117api.get("/favorites", (ctx) async {
118118 // Get a list of all the keys in the store
119- var keyStream = await favoritesKV .keys();
119+ var keys = await favouritesKV .keys();
120120
121- // Convert the keys to a list of favorites
122- var favorites = await keyStream.asyncMap((k) async {
123- final favorite = await favoritesKV.get(k);
121+ var favourites = await Future.wait(keys.map((k) async {
122+ final favourite = await favouritesKV.get(k);
124123
125- return favorite ;
126- }).toList();
124+ return favourite ;
125+ }).toList()) ;
127126
128127 // Return the body as a list of favorites
129128 ctx.res.body = jsonEncode(favorites);
@@ -147,10 +146,10 @@ api.post("/favorite", (ctx) async {
147146 final favorite = favorite.fromJson(req);
148147
149148 // search for the key, filtering by the name of the favorite
150- final stream = await favoritesKV.keys(prefix: favorite.name);
149+ final keys = await favoritesKV.keys(prefix: favorite.name);
151150
152151 // checks if the favorite exists in the list of keys
153- final exists = await stream .any((f) => f == favorite.name);
152+ final exists = keys .any((f) => f == favorite.name);
154153
155154 // if it exists delete and return
156155 if (exists) {
You can’t perform that action at this time.
0 commit comments