- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我想通过 json-server 测试 rest API。因此,首先我使用 npm 安装 json-server,然后使用以下数据创建 db.json:
[
{
"id": 1,
"name": "Angular Connect",
"date": "2036-09-25T23:00:00.000Z",
"time": "10:00 am",
"price": 599.99,
"imageUrl": "/assets/images/angularconnect-shield.png",
"location": {
"address": "1057 DT",
"city": "London",
"country": "England"
},
"sessions": [
{
"id": 1,
"name": "Using Angular 4 Pipes",
"presenter": "Peter Bacon Darwin",
"duration": 1,
"level": "Intermediate",
"abstract": "Learn all about the new pipes in Angular 4, both \n how to write them, and how to get the new AI CLI to write \n them for you. Given by the famous PBD, president of Angular \n University (formerly Oxford University)",
"voters": [
"bradgreen",
"igorminar",
"martinfowler"
]
},
{
"id": 2,
"name": "Getting the most out of your dev team",
"presenter": "Jeff Cross",
"duration": 1,
"level": "Intermediate",
"abstract": "We all know that our dev teams work hard, but with \n the right management they can be even more productive, without \n overworking them. In this session I'll show you how to get the \n best results from the talent you already have on staff.",
"voters": [
"johnpapa",
"bradgreen",
"igorminar",
"martinfowler"
]
},
{
"id": 3,
"name": "Angular 4 Performance Metrics",
"presenter": "Rob Wormald",
"duration": 2,
"level": "Advanced",
"abstract": "Angular 4 Performance is hot. In this session, we'll see \n how Angular gets such great performance by preloading data on \n your users devices before they even hit your site using the \n new predictive algorithms and thought reading software \n built into Angular 4.",
"voters": []
},
{
"id": 4,
"name": "Angular 5 Look Ahead",
"presenter": "Brad Green",
"duration": 2,
"level": "Advanced",
"abstract": "Even though Angular 5 is still 6 years away, we all want \n to know all about it so that we can spend endless hours in meetings \n debating if we should use Angular 4 or not. This talk will look at \n Angular 6 even though no code has yet been written for it. We'll \n look at what it might do, and how to convince your manager to \n hold off on any new apps until it's released",
"voters": []
},
{
"id": 5,
"name": "Basics of Angular 4",
"presenter": "John Papa",
"duration": 2,
"level": "Beginner",
"abstract": "It's time to learn the basics of Angular 4. This talk \n will give you everything you need to know about Angular 4 to \n get started with it today and be building UI's for your self \n driving cars and butler-bots in no time.",
"voters": [
"bradgreen",
"igorminar"
]
}
]
},
{
"id": 2,
"name": "ng-nl",
"date": "2037-04-14T23:00:00.000Z",
"time": "9:00 am",
"price": 950,
"imageUrl": "/assets/images/ng-nl.png",
"onlineUrl": "http://ng-nl.org/",
"sessions": [
{
"id": 1,
"name": "Testing Angular 4 Workshop",
"presenter": "Pascal Precht & Christoph Bergdorf",
"duration": 4,
"level": "Beginner",
"abstract": "In this 6 hour workshop you will learn not only how to test Angular 4, \n you will also learn how to make the most of your team's efforts. Other topics\n will be convincing your manager that testing is a good idea, and using the new\n protractor tool for end to end testing.",
"voters": [
"bradgreen",
"igorminar"
]
},
{
"id": 2,
"name": "Angular 4 and Firebase",
"presenter": "David East",
"duration": 3,
"level": "Intermediate",
"abstract": "In this workshop, David East will show you how to use Angular with the new\n ultra-real-time 5D Firebase back end, hosting platform, and wine recommendation engine.",
"voters": [
"bradgreen",
"igorminar",
"johnpapa"
]
},
{
"id": 3,
"name": "Reading the Angular 4 Source",
"presenter": "Patrick Stapleton",
"duration": 2,
"level": "Intermediate",
"abstract": "Angular 4's source code may be over 25 million lines of code, but it's really \n a lot easier to read and understand then you may think. Patrick Stapleton will talk\n about his secretes for keeping up with the changes, and navigating around the code.",
"voters": [
"martinfowler"
]
},
{
"id": 4,
"name": "Hail to the Lukas",
"presenter": "Lukas Ruebbelke",
"duration": 1,
"level": "Beginner",
"abstract": "In this session, Lukas will present the \n secret to being awesome, and how he became the President \n of the United States through his amazing programming skills, \n showing how you too can be success with just attitude.",
"voters": [
"bradgreen"
]
}
]
},
{
"id": 3,
"name": "ng-conf 2037",
"date": "2037-05-03T23:00:00.000Z",
"time": "9:00 am",
"price": 759,
"imageUrl": "/assets/images/ng-conf.png",
"location": {
"address": "The Palatial America Hotel",
"city": "Salt Lake City",
"country": "USA"
},
"sessions": [
{
"id": 1,
"name": "How Elm Powers Angular 4",
"presenter": "Murphy Randle",
"duration": 2,
"level": "Intermediate",
"abstract": "We all know that Angular is written in Elm, but did you\n know how the source code is really written? In this exciting look\n into the internals of Angular 4, we'll see exactly how Elm powers\n the framework, and what you can do to take advantage of this knowledge.",
"voters": [
"bradgreen",
"martinfowler",
"igorminar"
]
},
{
"id": 2,
"name": "Angular and React together",
"presenter": "Jamison Dance",
"duration": 2,
"level": "Intermediate",
"abstract": "React v449.6 has just been released. Let's see how to use \n this new version with Angular to create even more impressive applications.",
"voters": [
"bradgreen",
"martinfowler"
]
},
{
"id": 3,
"name": "Redux Woes",
"presenter": "Rob Wormald",
"duration": 1,
"level": "Intermediate",
"abstract": "Everyone is using Redux for everything from Angular to React to \n Excel macros, but you're still having trouble grasping it? We'll take a look\n at how farmers use Redux when harvesting grain as a great introduction to \n this game changing technology.",
"voters": [
"bradgreen",
"martinfowler",
"johnpapa"
]
},
{
"id": 4,
"name": "ng-wat again!!",
"presenter": "Shai Reznik",
"duration": 1,
"level": "Beginner",
"abstract": "Let's take a look at some of the stranger pieces of Angular 4,\n including neural net nets, Android in Androids, and using pipes with actual pipes.",
"voters": [
"bradgreen",
"martinfowler",
"igorminar",
"johnpapa"
]
},
{
"id": 5,
"name": "Dressed for Success",
"presenter": "Ward Bell",
"duration": 2,
"level": "Beginner",
"abstract": "Being a developer in 2037 is about more than just writing bug-free code. \n You also have to look the part. In this amazing expose, Ward will talk you through\n how to pick out the right clothes to make your coworkers and boss not only\n respect you, but also want to be your buddy.",
"voters": [
"bradgreen",
"martinfowler"
]
},
{
"id": 6,
"name": "These aren't the directives you're looking for",
"presenter": "John Papa",
"duration": 2,
"level": "Intermediate",
"abstract": "Coinciding with the release of Star Wars Episode 18, this talk will show how\n to use directives in your Angular 4 development while drawing lessons from the new movie,\n featuring all your favorite characters like Han Solo's ghost and Darth Jar Jar.",
"voters": [
"bradgreen",
"martinfowler"
]
}
]
},
{
"id": 4,
"name": "UN Angular Summit",
"date": "2037-06-09T23:00:00.000Z",
"time": "8:00 am",
"price": 800,
"imageUrl": "/assets/images/basic-shield.png",
"location": {
"address": "The UN Angular Center",
"city": "New York",
"country": "USA"
},
"sessions": [
{
"id": 1,
"name": "Diversity in Tech",
"presenter": "Sir Dave Smith",
"duration": 2,
"level": "Beginner",
"abstract": "Yes, we all work with cyborgs and androids and Martians, but \n we probably don't realize that sometimes our internal biases can make it difficult for\n these well-designed coworkers to really feel at home coding alongside us. This talk will\n look at things we can do to recognize our biases and counteract them.",
"voters": [
"bradgreen",
"igorminar"
]
},
{
"id": 2,
"name": "World Peace and Angular",
"presenter": "US Secretary of State Zach Galifianakis",
"duration": 2,
"level": "Beginner",
"abstract": "Angular has been used in most of the major peace brokering that has\n happened in the last decade, but there is still much we can do to remove all\n war from the world, and Angular will be a key part of that effort.",
"voters": [
"bradgreen",
"igorminar",
"johnpapa"
]
},
{
"id": 3,
"name": "Using Angular with Androids",
"presenter": "Dan Wahlin",
"duration": 3,
"level": "Advanced",
"abstract": "Androids may do everything for us now, allowing us to spend all day playing \n the latest Destiny DLC, but we can still improve the massages they give and the handmade\n brie they make using Angular 4. This session will show you how.",
"voters": [
"igorminar",
"johnpapa"
]
}
]
},
{
"id": 5,
"name": "ng-vegas",
"date": "2037-02-10T00:00:00.000Z",
"time": "9:00 am",
"price": 400,
"imageUrl": "/assets/images/ng-vegas.png",
"location": {
"address": "The Excalibur",
"city": "Las Vegas",
"country": "USA"
},
"sessions": [
{
"id": 1,
"name": "Gambling with Angular",
"presenter": "John Papa",
"duration": 1,
"level": "Intermediate",
"abstract": "No, this talk isn't about slot machines. We all know that \n Angular is used in most waiter-bots and coke vending machines, but\n did you know that was also used to write the core engine in the majority\n of voting machines? This talk will look at how all presidential elections\n are now determined by Angular code.",
"voters": [
"bradgreen",
"igorminar"
]
},
{
"id": 2,
"name": "Angular 4 in 60ish Minutes",
"presenter": "Dan Wahlin",
"duration": 2,
"level": "Beginner",
"abstract": "Get the skinny on Angular 4 for anyone new to this great new technology.\n Dan Wahlin will show you how you can get started with Angular in 60ish minutes, \n guaranteed!",
"voters": [
"bradgreen",
"igorminar",
"johnpapa"
]
}
]
}
]
在 package.json 脚本中添加以下命令后:
"json-server": "json-server --watch db.json"
但是当我用这个命令运行服务器时:npm run json-server
我收到以下错误消息:
Loading db.json Done
Data must be an object. Found object.See https://github.com/typicode/json-server for example.
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! events@0.0.0 json-server:
json-server --watch db.json
npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the events@0.0.0 json-server script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\maoutir\AppData\Roaming\npm-cache_logs\2018-09-17T09_59_06_721Z-debug.log
非常感谢任何帮助。预先感谢您的帮助。
最佳答案
您的 json 文件需要是一个基本级别的对象。
{
"data": [//the rest of your data]
}
关于node.js - Json 服务器的 Rest API 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52365586/
关闭。这个问题是off-topic .它目前不接受答案。 想要改进这个问题? Update the question所以它是on-topic用于堆栈溢出。 关闭 12 年前。 Improve thi
我有一个动态网格,其中的数据功能需要正常工作,这样我才能逐步复制网格中的数据。假设在第 5 行中,我输入 10,则从第 6 行开始的后续行应从 11 开始读取,依此类推。 如果我转到空白的第一行并输入
我有一个关于我的按钮消失的问题 我已经把一个图像作为我的按钮 用这个函数动画 function example_animate(px) { $('#cont
我有一个具有 Facebook 连接和经典用户名/密码登录的网站。目前,如果用户单击 facebook_connect 按钮,系统即可运行。但是,我想将现有帐户链接到 facebook,因为用户可以选
我有一个正在为 iOS 开发的应用程序,该应用程序执行以下操作 加载和设置注释并启动核心定位和缩放到位置。 map 上有很多注释,从数据加载不会花很长时间,但将它们实际渲染到 map 上需要一段时间。
我被推荐使用 Heroku for Ruby on Rails 托管,到目前为止,我认为我真的会喜欢它。只是想知道是否有人可以帮助我找出问题所在。 我按照那里的说明在该网站上创建应用程序,创建并提交
我看过很多关于 SSL 错误的帖子和信息,我自己也偶然发现了一个。 我正在尝试使用 GlobalSign CA BE 证书通过 Android WebView 访问网页,但出现了不可信错误。 对于大多
我想开始使用 OpenGL 3+ 和 4,但我在使用 Glew 时遇到了问题。我试图将 glew32.lib 包含在附加依赖项中,并且我已将库和 .dll 移动到主文件夹中,因此不应该有任何路径问题。
我已经盯着这两个下载页面的源代码看了一段时间,但我似乎找不到问题。 我有两个下载页面,一个 javascript 可以工作,一个没有。 工作:http://justupload.it/v/lfd7不是
我一直在使用 jQuery,只是尝试在单击链接时替换文本字段以及隐藏/显示内容项。它似乎在 IE 中工作得很好,但我似乎无法让它在 FF 中工作。 我的 jQuery: $(function() {
我正在尝试为 NDK 编译套接字库,但出现以下两个错误: error: 'close' was not declared in this scope 和 error: 'min' is not a m
我正在使用 Selenium 浏览器自动化框架测试网站。在测试过程中,我切换到特定的框架,我们将其称为“frame_1”。后来,我在 Select 类中使用了 deselectAll() 方法。不久之
我正在尝试通过 Python 创建到 Heroku PostgreSQL 数据库的连接。我将 Windows10 与 Python 3.6.8 和 PostgreSQL 9.6 一起使用。 我从“ht
我有一个包含 2 列的数据框,我想根据两列之间的比较创建第三列。 所以逻辑是:第 1 列 val = 3,第 2 列 val = 4,因此新列值什么都没有 第 1 列 val = 3,第 2 列 va
我想知道如何调试 iphone 5 中的 css 问题。 我尝试使用 firelite 插件。但是从纵向旋转到横向时,火石占据了整个屏幕。 有没有其他方法可以调试 iphone 5 中的 css 问题
所以我有点难以理解为什么这不起作用。我正在尝试替换我正在处理的示例站点上的类别复选框。我试图让它做以下事情:未选中时以一种方式出现,悬停时以另一种方式出现(选中或未选中)选中时以第三种方式出现(而不是
Javascript CSS 问题: 我正在使用一个文本框来写入一个 div。我使用以下 javascript 获取文本框来执行此操作: function process_input(){
你好,我很难理解 P、NP 和多项式时间缩减的主题。我试过在网上搜索它并问过我的一些 friend ,但我没有得到任何好的答案。 我想问一个关于这个话题的一般性问题: 设 A,B 为 P 中的语言(或
你好,我一直在研究 https://leetcode.com/problems/2-keys-keyboard/并想到了这个动态规划问题。 您从空白页上的“A”开始,完成后得到一个数字 n,页面上应该
我正在使用 Cocoapods 和 KIF 在 Xcode 服务器上运行持续集成。我已经成功地为一个项目设置了它来报告每次提交。我现在正在使用第二个项目并收到错误: Bot Issue: warnin
我是一名优秀的程序员,十分优秀!