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

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.

主站蜘蛛池模板: 灵石县| 曲麻莱县| 塔河县| 三亚市| 溧水县| 连州市| 梅河口市| 黎平县| 厦门市| 扎兰屯市| 内江市| 霍城县| 慈溪市| 马尔康县| 寻甸| 白城市| 天峻县| 连南| 乐陵市| 时尚| 和平县| 始兴县| 石渠县| 凯里市| 英德市| 岳阳县| 驻马店市| 景德镇市| 郧西县| 辽宁省| 萝北县| 丰台区| 新泰市| 麻城市| 泗洪县| 滦平县| 乌什县| 潮州市| 珲春市| 治多县| 大冶市|