user555
user555

Reputation: 1529

redirect to page call from server in meteor

I'm using iron router and

In the serve I've a http method

in server/methods.js

  '/fail':function(data){
            console.log("fail");
            console.log(data);
            return "<h5>Your payment is failed.<a href='/'>Click here</a> to go back to site</h5>"
        }

when calling this method I don't want to display simple message, I want to redirect to url

How to do this using iron:router

I tried using Router.go It is saying object has no method go

My router code is in

lib/router.js

EDIT

https://github.com/CollectionFS/Meteor-http-methods

The method above declared is a http-method using the above package

I'm using this method on my server and

I've integrated some api in my application that api sends post request to /fail url

this is all working fine and I'm able to process the data also

but after processing the data I want to return to some url.

Upvotes: 2

Views: 451

Answers (2)

Brandon Mansfield
Brandon Mansfield

Reputation: 1

You can always fall back to base HTTP. This is the only method I've found that works.

'/fail':function(data){
        console.log("fail");
        console.log(data);
        this.response.statusCode = 302;
        this.response.setHeader('Location', '/');
        this.response.end('See ya');
    }

Upvotes: 0

Willem Mulder
Willem Mulder

Reputation: 13994

As far as I can see, the .go method only works on a Router instance, not on the Router global object itself, so maybe that is the issue?

Also, it appears that the .go function is only available on the client, not on the server. So that might be a thing as well...

Upvotes: 1

Related Questions