Skip to content

Instantly share code, notes, and snippets.

@herzzanu
Last active February 10, 2021 10:32
Show Gist options
  • Save herzzanu/aac8944fa00219a8d33542bfcc96184e to your computer and use it in GitHub Desktop.
Save herzzanu/aac8944fa00219a8d33542bfcc96184e to your computer and use it in GitHub Desktop.
Multi transfers route handler with reading and parsing the file
// mirage/config.js - Mocking with factories and the data from the request file
this.post('/multi_transfers', async function (schema, request) {
let file = request.requestBody.get('multi_transfer[file][file]');
let fileContents = await readFile(file);
let transferData = parseCSV(fileContents);
let multiTransfer = server.create('multi-transfer', {
status: 'pending',
...transferData,
});
return multiTransfer;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment