Search code examples
responsesproutcore

How to fake a response using 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.


Solution

  • 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.