Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mocks for mockserver for fetch requests. Run with: mockserver -p 5555 -m './'
/* eslint-disable */
// parse the body and give it back so it gets re-stringified
// must be `enctype="multipart/form-data"`
module.exports = request.body.split('------')
.map(str => str.replace(/\n+/g, ' ').trim().match(/"(\w+)\b"\s+(\w+)/g))
.filter(Boolean)
.join('\n')
.replace(/\"\s+/g, '": ');
HTTP/1.1 204 No Content
Allow: OPTIONS, GET, HEAD, POST
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: OPTIONS, GET, HEAD, POST
Access-Control-Allow-Headers: Authorization,content-type
Access-Control-Allow-Credentials: true
Content-Length: 0
Content-Type: text/plain
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST
Access-Control-Allow-Headers: Authorization,content-type
Access-Control-Allow-Credentials: true
#import './body.js';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.