http function and saml integration

I was trying to integrated with wix and saml, using saml2-js module and http-function.

Here’s the code I used for saml redirection but failed with 500 error:

export function get_login(request) {
 let redirect_login_url = null;

    sp.create_login_request_url(idp, {}, function (err, login_url, request_id) {
        redirect_login_url = (err === null) ?
            login_url :
            null
    });

 return redirect_login_url !== null ?
        response({ status: 301, headers: { "Location": redirect_login_url } }) : 
        serverError()

}


It’s found that login_url didn’t get assigned to redirect_login_url.

What can I do make redirect_login_url in get_login scope accessible to the anonymous callback ?