Using Mirage i need to mock my GET request which returns data in the form of binary string (the format is gzip). It is my first time using mirage and i don't know if i'm mocking a binary response, should I return a valid value? here is how i mocked it for now.
this.get('/myproxy/api/v1/network/download', function (db, request) {
let responseBlob = new window.Blob(['To be replaced with my actual binary data'], {type: 'application/octet-stream'})
return new Response(
200,
{'content-disposition': "attachment; filename=network.myextension; filename*=UTF-8''network.myextension"},
responseBlob
)
})
Here is my scenario: Upon receiving response from backend, i just convert the repose to blob and download it as a file. If i should create a valid binary data when i'm mocking data, how can i do it using mirage? should i store it as a file somewhere and use it as the mocked response? I appreciate if someone can help me.
Aucun commentaire:
Enregistrer un commentaire