jquery-mockjax icon indicating copy to clipboard operation
jquery-mockjax copied to clipboard

Dynamically Generating Mock Definitions

Open Vladzimir opened this issue 5 years ago • 1 comments

$.mockjax(function(settings) {

// settings.url might be: "/restful/" such as "/restful/user"

var service = settings.url.match(//restful/(.*)$/); if ( service ) { return { proxy: "/mocks/" + service[1] + ".json" }; } // If you get here, there was no url match return; });

Using this method fails to redirect POST data to proxy url Have to use crutches

proxyType: settings.type, data: settings.data, headers: settings.headers, contentType: settings.contentType

Vladzimir avatar Oct 23 '20 17:10 Vladzimir

Hmm... well, that's not a valid regex, but maybe you've already escaped it and GitHub just isn't checking properly?

This: settings.url.match(//restful/(.*)$/); should probably be: settings.url.match(/\/restful\/(.*)$/);

I'll have to write a little test to see if I can replicate this.

jakerella avatar Nov 03 '20 02:11 jakerella