박권수

feat. new bottle update

...@@ -100,8 +100,8 @@ exports.lookupInfo = async(ctx) => { ...@@ -100,8 +100,8 @@ exports.lookupInfo = async(ctx) => {
100 const { userId } = jwt.verify(token, process.env.JWT_SECRET); 100 const { userId } = jwt.verify(token, process.env.JWT_SECRET);
101 const { bottleId } = ctx.params; 101 const { bottleId } = ctx.params;
102 102
103 - const bottle = await Bottle.findByBottleId(bottleId); 103 + const isBottleExist = await Bottle.findByBottleId(bottleId);
104 - if(!bottle) { 104 + if(!isBottleExist) {
105 ctx.status = 404; 105 ctx.status = 404;
106 return; 106 return;
107 } 107 }
...@@ -117,7 +117,9 @@ exports.lookupInfo = async(ctx) => { ...@@ -117,7 +117,9 @@ exports.lookupInfo = async(ctx) => {
117 const client = await Mqtt.mqttOn(hosting); 117 const client = await Mqtt.mqttOn(hosting);
118 const topic = 'bottle/' + bottleId + '/stb'; 118 const topic = 'bottle/' + bottleId + '/stb';
119 const message = 'req'; 119 const message = 'req';
120 - Mqtt.mqttPublishMessage(client, { topic, message }); 120 + await Mqtt.mqttPublishMessage(client, { topic, message });
121 +
122 + const bottle = await Bottle.findByBottleId(bottleId);
121 123
122 ctx.status = 200; 124 ctx.status = 200;
123 ctx.body = bottle; 125 ctx.body = bottle;
......