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

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.

主站蜘蛛池模板: 吉水县| 德保县| 象山县| 永仁县| 鄂托克前旗| 万盛区| 象州县| 五台县| 师宗县| 齐齐哈尔市| 元谋县| 永泰县| 衡山县| 安溪县| 河南省| 南丹县| 临澧县| 永福县| 江门市| 塔河县| 独山县| 长汀县| 北票市| 大港区| 砚山县| 惠安县| 高陵县| 吴江市| 凌海市| 白朗县| 天祝| 三穗县| 东平县| 井冈山市| 福贡县| 方山县| 泊头市| 大港区| 格尔木市| 广宁县| 山东省|