如何使用 sc-server 伪造响应

发布于 2025-01-02 19:06:40 字数 483 浏览 4 评论 0原文

我想在开发模式下执行此代码:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷情 2025-01-09 19:06:40

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文