Webflow script for pulling URL and then redirecting

Options
[Screen Shot 2022-03-11 at 10.31.25 am.png]Hi all,

I'm attempting to pull a link from a Stripe onboarding API (which, by the way, works in the debugger in Xano). The user clicks a button, the API is called, the link is pulled and passed to Webflow, and the user then needs to be redirected.

It doesn't seem like a difficult thing, but I don't know the script for Webflow. Can anyone help?

Comments

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options
    At the risk of breaking up the no-code vibe: in my experience, often this is handled with a small bit of javascript on WebFlow. How it gets triggered depends on how you have set the button to call the API. (and if you haven't yet - it's not that bad using $.ajax) Within that snippet you would extract the target URL from result as stripeUrl, and then run:

    window.location.href = stripeUrl

    and you will get redirected immediately. 

    This can be easier to show and walk through than tell, so let me know if I can help better! 
  • Lachlan Hamilton
    Options
     Hi Ray - thanks so much. Yes, completely aware that it's my webflow code that I need to get right. This is what someone wrote out for me, and I added the API url:

    function createStripeExpressLink() {
    // URL here is your link
    fetch('https://x8ki-letl-twmt.n7.xano.io/api:G2T11kbZ/CreateStripeExpressLink?account=accountID')
    .then(res => res.json()) // extract json response
    .then(result => { // process json res result and redirect
    const redirectURL = result.url
    window.location.href = redirectURL
    })
    }
  • Lachlan Hamilton
    Options
    I just ran that - Xano is showing a GET request instead of what should be a POST request.
  • Lachlan Hamilton
    Options
     Would love your help on this Ray, have opened a chat on your site. Look forward to chatting soon.
  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options
     wonderful!