Comments (6)
And as a feature request it would be cool if you could use different success files for different params.
Like success{id}.json and the you name the files success1.json, success2.json, and so on!
from node-mock-server.
@JonWallsten Currently it's just possible to use query params as ejs variables query param in ejs
I will add the dynamic path to ejs object.
The solution (with future version 0.7.2 #9) will be:
{
"id": <%=params.id%>,
name: "<%-faker.name.firstName();%>"
}
You question about how to change the mock response:
- Change the expected response by using the UI
- Use the query param
_expected=error
- Use the request header
_expected=error
An automatic check for not existing dynamic path is currently not implemented #8 .
from node-mock-server.
Cool! Then I'll wait for the next release.
Ah, i see! I thought it could be done automagically! ;)
Thanks!
from node-mock-server.
{
"id": 1,
"campaignId": <%=id%>,
"name": "Test"
}
I get a reference error:
"id" is not defined.
path: undefined.
Is it because I'm using /rest/test/1 instead of /rest/test/?id=1 ?
from node-mock-server.
@JonWallsten
Yes that's because you use /rest/test/1 instead of /rest/test/?id=1
0.7.2
is released - npm install [email protected]
which includes the two issues, has arisen from your questions.
With the new release you can use this:
{
"id": <%=params.id%>,
name: "<%-faker.name.firstName();%>"
}
I hope it works as you had assumed.
Thanks for your feedback and questions.
from node-mock-server.
Thank you! That's awesome!
from node-mock-server.
Related Issues (20)
- 413 Error: request entity too large HOT 2
- Tunnels with https target HOT 3
- node-mock-server doesn't parse 'application/json' content type HOT 1
- Import Swagger doesn't parse $ref HOT 1
- react-dev-utils as "dependency" instead of "devDependency" HOT 1
- Swagger Import does not generate response schema
- CORS: Error during options request HOT 1
- How to handle xml response in mock-server HOT 2
- It doesnโt copy example responses from swagger HOT 2
- Docker support for node mock server HOT 1
- Switching between configured Responses HOT 1
- HTTP code does work with response header HOT 1
- Can someone help me deploy this on Azure or google cloud? HOT 1
- cors issue HOT 1
- How to mock image type GET responses? HOT 1
- UI freezes when refreshing after removing endpoint from filesystem
- Switching to middleware automatically HOT 1
- Doubt about func-imported when import swagger, error400, Collections and more
- How to mocking delay response HOT 1
- [question] options.accessControlAllowOrigin (and others) not send when using middleware
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-mock-server.