Comments (8)
应该是404返回Not Found, 然后你调用res.json()的时候没法把Not Found解析成JSON,于是报错说第一个字母N词法错误。
感觉要么是fetch请求格式有错, 要么是后端解析请求格式解析错了,稍后我做一下测试
from blog.
我尝试了一下,浏览器环境的fetch和node环境的fetch都没问题啊。
from blog.
你函数中headers里没有authorization字段应该会被服务器拒绝修改的,你是不是自己修改了permission函数?koa2中在回调里调用next函数就会出现你这种情况,应当将回调的形式改为co/generator或者async/await这样的假协程形式
另外可以贴一下浏览器network页面中patch请求的详情,确保发起的请求没有问题
from blog.
谢谢,看了你的分析之后,我找到问题出现所在了。
因为还没做到验证登录那块,所以我直接把permission函数里面的内容注释掉了,只写了个next(),就出现了以上的问题。
我的解决方法: return netxt();
这样就。。解决了!
是因为koa-router里面的中间件必须return一个值吗?
from blog.
koa2中的next()返回的是promise,估计koa中检查到非promise的返回值时就直接跳到默认的Error Handler中间件了
from blog.
原来是这样,谢谢你啦!
我还想问一下,如果前后台都写好了,准备上线自己的博客,因为服务器端的koa2只是一个简单的REST服务器,那么前后台的网页应该放哪?
还是直接修改koa2去render前后台的网页呢?
from blog.
看你是前后端分离还是传统的MVC咯,前后端分离的话构建出静态资源用nginx代理即可,传统MVC还需要nginx额外配置端口的信息。前者的nginx可以参考本博客admin的部署nginx模板,后者可以参考本博客front的部署nginx文档,都在readme里有写
from blog.
谢谢!
from blog.
Related Issues (16)
- 带我一个玩呗? HOT 8
- 几点建议 HOT 9
- Todo列表 HOT 22
- Dockerfile 无法正常使用 HOT 1
- build后,部署到服务器上,如何启动?? HOT 5
- 单独跑server端插件依赖报错 HOT 2
- api.js 这段代码不太理解,import api from 'create-api' ,这个引用在那里 HOT 2
- 关于七牛图片上传 HOT 1
- 在blog列表页点击文字链接进入的时候先显示的是上次加载的内容 HOT 4
- git clone front 项目后断开网络没有离线存储 HOT 1
- 向大佬学习
- vue的ssr怎么配置webpack HOT 1
- 前端安装失败 HOT 1
- 文章页内容的展示 HOT 12
- Front 部分的 mongo 配置未暴露出来以及一处文档错误 HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blog.