Last active
February 10, 2021 10:32
-
-
Save herzzanu/aac8944fa00219a8d33542bfcc96184e to your computer and use it in GitHub Desktop.
Multi transfers route handler with reading and parsing the file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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