Could I use "res.setHeader, res.statusCode" in Meteor.methods()?

Could I use “res.setHeader, res.statusCode” in Meteor.methods()?

    exportDump: function () {
     var res = .............;
      res.statusCode = 200;

      return ........;

There is no HTTP request so it doesn’t make any sense. Most of those calls are send over the Websocket.

If you would like to handle error with, you can throw errors within your methods. It seems to be the best practice.

Thanks for your reply, I don’t want to use Server Router in my package.
How to solve this.

Hi, it is not clear why you need such feature inside Meteor.methods? Could you explain the use case?

I create backup-restore Meteor Package via mongodb-backup NPM package.
But I don’t want to use router to response the backup.tar file like this

res.writeHead(200, {
    'Content-Type': 'application/x-tar' // force header for tar download

    uri: 'uri', // mongodb://<dbuser>:<dbpassword>@<dbdomain><dbport>/<dbdatabase>
    collections: [ 'logins' ], // save this collection only
    stream: res, // send stream into client response

So I want to use Methods.

You cannot use http server features like streams with Methods. Methods work with DDP messages over websocket in common. So it is more suitable to use some Router (connect) for the issue.

If you do not want to include any external router package you can use core WebApp package and handle routes with connect. See Webapp docs

Thanks, good look :smiley:
But I don’t see how to get the params/query.

you should use node.js core url or any connect middleware as Meteor or any routing package does.