Where does this go???

 .then( (results) => { 
  	wixLocation.to(`/MemberProfile/${wixUsers.currentUser.id}`); 
  	// if an item for the user is not found 
    if (results.items.length === 0) { 
    wixLocation.to(`/createaccount/`); 	 **<<<<<<<<<<<<<<<<<<<<<<1. HERE?** 
      // create an item 
      const toInsert = { 
        "_id": userId, 
        "email": userEmail 
      }; 
      wixLocation.to(`/createaccount/`);  **<<<<<<<<<<<<<<<<<<<<<<2. HERE?** 
      // add the item to the collection 
      wixData.insert("Members", toInsert) 
        .catch( (err) => { 
          console.log(err); 
        } ); 
        wixLocation.to(`/createaccount/`);  **<<<<<<<<<<<<<<<<<<<<<<3. HERE?** 

Somewhere else?

I’ve tried all three locations but it’s not working. Can someone help?

Hey,
The page name should be without the last backslash:
wixLocation.to (/createaccount);
Click here to learn more about Wix Location API.

Should the issue persists, please provide us with more info about the use case and what you would like to achieve. Moreover, note that you pasted only part of the function…

Good luck!
Tal.

Hey Tal,
Thanks, I fixed the function so it’s right now, but the location is still the issue, or unless there’s something I’m not adding.

I’m trying to {wixLocation.to(“/createaccount”);} a user who “signs up” using the prompt and gets directed to my /createaccount page, but if they already have an approved account and they log in, it directs them to their /MemberProfile page.

Right now I have it all the way at the top when it loads the prompt, but it’s not ideal.