如何使用 sc-server 伪造响应
我想在开发模式下执行此代码:
App.statecharts.someState = SC.State.design({
enterState: function() {
SC.Request
.getUrl('/someUrl')
.json()
.header({ 'Accept': 'application/json' })
.notify(this, 'checkIsAnswer')
.send();
},
checkIsAnswer: function(response) {
console.log(response);
}
});
为此,我需要伪造来自服务器的响应。
例如。 http://localhost:4020/someUrl
应该是静态 JSON
如何使用 sc-server
伪造此响应。
I want to execute this code in development mode:
App.statecharts.someState = SC.State.design({
enterState: function() {
SC.Request
.getUrl('/someUrl')
.json()
.header({ 'Accept': 'application/json' })
.notify(this, 'checkIsAnswer')
.send();
},
checkIsAnswer: function(response) {
console.log(response);
}
});
To do so I need to fake the response from the server.
Eg. http://localhost:4020/someUrl
schould be a static JSON
How to fake this response using sc-server
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
sc-server
有一个代理。尝试添加
proxy '/someUrl', :to =>; 'myinternalserver.com:9090'
添加到您的构建文件中。然后,您可以从
http://myinternalserver.com:9090/someUrl
访问硬编码的虚假 JSON 响应。任何网络服务器都可以。希望这有帮助。
sc-server
has a proxy.Try adding
proxy '/someUrl', :to => 'myinternalserver.com:9090'
to your Buildfile.You can then make your hard coded fake JSON response accessible from
http://myinternalserver.com:9090/someUrl
. Any web server will do.Hope this helps.