Downloading csv file Loopback -


i have remote method in loopback

    usermodel.exporting = function(type, resp, cb) {     var result;     var fields = ['first_name', 'last_name'];     var data = ["first name ","last name"]             result = json2csv({ data: data, fields: fields });             resp.setheader('content-disposition', 'attachment; filename=users.csv');             resp.set('content-type', 'text/csv');             resp.send(result);         }) }     usermodel.remotemethod('exporting', {     accepts: [         { arg: 'type', type: 'string' },         { arg: 'res', type: 'object', 'http': { source: 'res' } }     ],     returns: {},     http: { path: '/csvexport/:type', verb: 'get' } }); 

i trying download csv file on client side code downloading file file not in csv , not formatted.what doing wrong? thanks.


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -