Browse Source

fix a bug

chenhaiyang 4 years ago
parent
commit
c593eb25c0
1 changed files with 6 additions and 3 deletions
  1. 6 3
      app/api/routers/bluetooth.py

+ 6 - 3
app/api/routers/bluetooth.py

@@ -14,9 +14,12 @@ router = APIRouter()
 @router.post('/user/{user_id}', response_model=BluetoothUserResponse)
 async def create_bluetooth_info(user_id: str, bluetooth_info: List[BluetoothCreate]):
     valid_data = []
-    for item in bluetooth_info:
-        if len(item.advertisData) == 31:
-            valid_data.append(item)
+    try:
+        for item in bluetooth_info:
+            if len(item.advertisData) == 31:
+                valid_data.append(item)
+    except TypeError:
+        pass
     logger.debug(valid_data)
     info_list = [item.dict() for item in bluetooth_info]
     logger.info(f'{user_id}: {info_list}')