官术网_书友最值得收藏!

Running the getNote function

Now that we have this in place we can test out this brand new functionality inside of Terminal by running our app using node app.js. I'll use the read command, and I'll pass in a title equal to some string that I know does not exist inside of a title in the notes-data.json file:

node app.js read --title="something here"

When I run the command, we get Note not found, as shown here, and this is exactly what we want:

Now, if I do try to fetch a note where the title does exist, I would expect that note to come back.

In the data file I have a note with a title of to buy; let's try to fetch that one. I'll use the up arrow key to populate the previous command and replace the title with to space, buy, and hit enter:

As shown in the previous code, you can see Note found prints to the screen, which is fantastic. Following Note found we have our spacers and following that we have the title, which is to buy, and the body, which is food, exactly as it appears inside of the data file. With this in place, we are done with the read command.

主站蜘蛛池模板: 桑植县| 宝丰县| 星子县| 息烽县| 乐山市| 旺苍县| 上杭县| 香河县| 阳江市| 巴林右旗| 清远市| 博乐市| 通海县| 锡林浩特市| 平湖市| 古蔺县| 穆棱市| 云浮市| 和硕县| 莱阳市| 内江市| 台江县| 新余市| 凤阳县| 玉环县| 明溪县| 苏州市| 桦南县| 和硕县| 天峨县| 凤冈县| 永康市| 云南省| 钟祥市| 松阳县| 盘锦市| 肥西县| 海林市| 阆中市| 河间市| 铜川市|