Commit 541ddfa2 authored by Geovanny's avatar Geovanny

Added checkers when there is no rows in the DB

parent bcdaeacd
...@@ -117,7 +117,7 @@ class UnitManager(commands.Cog): ...@@ -117,7 +117,7 @@ class UnitManager(commands.Cog):
"""Gets all units""" """Gets all units"""
data = await Api.get('/unit/all') data = await Api.get('/unit/all')
if data == None: if(data==None or len(data['units'])==0):
return await ctx.send('No units found') return await ctx.send('No units found')
units_data = [] units_data = []
......
...@@ -38,6 +38,9 @@ router.get('/units', async (context, next) => { ...@@ -38,6 +38,9 @@ router.get('/units', async (context, next) => {
checkUser(context); checkUser(context);
try{ try{
const data = await userModel.getUserUnits(context.session.user_id); const data = await userModel.getUserUnits(context.session.user_id);
if(data.length===1 && data[0].id===null){
throw Error('No Units Found')
}
context.response.body = {units: data}; context.response.body = {units: data};
context.status = 200; context.status = 200;
}catch(error){ }catch(error){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment