Differences
This shows you the differences between two versions of the page.
frontend [2020/10/01 16:34] paul created |
frontend [2020/10/01 17:02] (current) paul |
||
---|---|---|---|
Line 21: | Line 21: | ||
], | ], | ||
})) | })) | ||
+ | </ | ||
+ | |||
+ | ===== Dynamic Requests ===== | ||
+ | |||
+ | In Mirage JS there is a backend database that can be defined by Models and accessed using the Schema methods. | ||
+ | |||
+ | <code javascript> | ||
+ | import { createServer, | ||
+ | |||
+ | export default function () { | ||
+ | createServer({ | ||
+ | |||
+ | models: { | ||
+ | reminder: Model, | ||
+ | }, | ||
+ | |||
+ | routes() { | ||
+ | this.get("/ | ||
+ | |||
+ | this.post(" | ||
+ | let attrs = JSON.parse(request.requestBody); | ||
+ | |||
+ | return schema.reminders.create(attrs); | ||
+ | }) | ||
+ | }, | ||
+ | }) | ||
+ | } | ||
</ | </ |