json - 使用 Axios 在 JSON-SERVER 上将数据作为新资源发布?
问题描述
我正在尝试将数据作为新资源发布到服务器上,该怎么做?
将数据作为资源发布的代码:
const postData = async () => {
const response = await axios.post('http://localhost:3000/', { newResource: [{id:2,name:'b'}] });
response.then((response)=>{
console.log(response.data)
})
};
添加资源之前的 db.json:
{
"oldResource": [
{
"id": 1,
"name": "a",
}
]
}
添加资源后我想要db.json:
{
"oldResource": [
{
"id": 1,
"name": "a",
}
],
"newResource": [
{
"id": 2,
"name": "b",
}
]
}
问题 它说 404 未找到。
什么是磨损或没有办法做到这一点?请帮忙!
解决方案
推荐阅读
- python - 如何在我的 BeautifulSoup WebScraper 中实现多处理
- unit-testing - 避免线程休眠单元测试
- python - Firebase 管理员 Firestore 错误:“查询”对象没有属性“流”
- r - 我们可以创建一个具有唯一值的索引吗
- angular - d3v5 Angular 6 Universal - 错误类型错误:(void 0)不是函数
- jdbc - 使用 pyspark 写入云 DB2 表
- babeljs - 是否可以在 @babel/cli 运行之间使用缓存?
- angular - 对话框堆栈工作流程 Angular Material
- sql - 从python中的更大查询中获取所有子查询
- excel - 在 word doc 中查找唯一文本并从此 word doc 中复制连续的字符串,来自 excel vba