我想在开发模式下执行以下代码:
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
伪造此响应。
最佳答案
sc-server
有一个代理。
尝试将proxy '/someUrl', :to => 'myinternalserver.com:9090'
添加到您的Buildfile中。
然后,您可以通过http://myinternalserver.com:9090/someUrl
来访问您的硬编码假JSON响应。任何Web服务器都可以。
希望这可以帮助。
关于response - 如何使用sc-server伪造响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9165192/