Showing
1 changed file
with
3 additions
and
2 deletions
| ... | @@ -4,6 +4,7 @@ const Hub = require('../../models/hub'); | ... | @@ -4,6 +4,7 @@ const Hub = require('../../models/hub'); |
| 4 | const Medicine = require('../../models/medicine'); | 4 | const Medicine = require('../../models/medicine'); |
| 5 | const Mqtt = require('../../lib/MqttModule'); | 5 | const Mqtt = require('../../lib/MqttModule'); |
| 6 | const jwt = require('jsonwebtoken'); | 6 | const jwt = require('jsonwebtoken'); |
| 7 | +const hub = require('../../models/hub'); | ||
| 7 | 8 | ||
| 8 | //약병 등록 | 9 | //약병 등록 |
| 9 | exports.bottleConnect = async(ctx) => { | 10 | exports.bottleConnect = async(ctx) => { |
| ... | @@ -172,13 +173,13 @@ exports.getBottleList = async(ctx) => { | ... | @@ -172,13 +173,13 @@ exports.getBottleList = async(ctx) => { |
| 172 | 173 | ||
| 173 | const { userId } = jwt.verify(token, process.env.JWT_SECRET); | 174 | const { userId } = jwt.verify(token, process.env.JWT_SECRET); |
| 174 | const hubList = await Hub.find({ userId }) | 175 | const hubList = await Hub.find({ userId }) |
| 175 | - if(!hubList) { | 176 | + if(!hubList || !hubList.length) { |
| 176 | ctx.status = 404; | 177 | ctx.status = 404; |
| 177 | return; | 178 | return; |
| 178 | } | 179 | } |
| 179 | 180 | ||
| 180 | const bottleList = await getBottleListByHub(hubList); | 181 | const bottleList = await getBottleListByHub(hubList); |
| 181 | - if(!bottleList) { | 182 | + if(!bottleList || !bottleList.length) { |
| 182 | ctx.status = 404; | 183 | ctx.status = 404; |
| 183 | return; | 184 | return; |
| 184 | } | 185 | } | ... | ... |
-
Please register or login to post a comment