So I know already that /my/billing/subscriptions is a way to link the current user to his or her own user profile, in particular, the billing section that comes with Discourse Subscriptions. However, this doesn’t seem to be working in my code below, with the expression within the if-statement. In particular, I am trying to get a button to show up only on the user’s billing page. In fact, it seems to not work for any URL of the form /my, whether it’s billing, preferences, activity, or whatever else. Am I doing something wrong? What should I be using? (Keep in mind this is only not working in the if-statement. Otherwise using /my has and is working fine.)
EDIT: So, using console.log I was able to figure out that in general this approach works fine. For example, if I just put the code
const user = api.getCurrentUser()
console.log("/u/" + user.username + "/billing/subscriptions")
in a script, I get back the desired /u/Miles/billing/subscriptions.
However, the problem occurs when I try to put this inside of setupComponent(args, component) {}. Once I do this, console.log no longer shows anything. Still not sure what I’m doing wrong…
I thought so, because there is the use of api.onPageChange(url) already there a being executed just fine. Note that I am adapting the code from here, so it seems it’s very well true that I have access to the api object in the setupComponent method.
Just for further clarification, here is what I got so far: