Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically Generating Mock Definitions #359

Open
Vladzimir opened this issue Oct 23, 2020 · 1 comment
Open

Dynamically Generating Mock Definitions #359

Vladzimir opened this issue Oct 23, 2020 · 1 comment
Assignees
Labels

Comments

@Vladzimir
Copy link

Vladzimir commented Oct 23, 2020

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

@jakerella
Copy link
Owner

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 jakerella self-assigned this Nov 3, 2020
@jakerella jakerella added the Bug label Nov 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants