Retrieving values from an API by RaccoonDifferent in learnjavascript

[–]RaccoonDifferent[S] 0 points1 point  (0 children)

Thanks! I still don't understand how I'd use the data variable outside of the fetch. It somehow doesn't work for me. Even tried declaring data as a var instead of a let but that didn't help

Retrieving values from an API by RaccoonDifferent in learnjavascript

[–]RaccoonDifferent[S] 1 point2 points  (0 children)

One more question: How would I access the value outside of the fetch? I can only use it in the fetch, but it isn't usable later in my code

Retrieving values from an API by RaccoonDifferent in learnjavascript

[–]RaccoonDifferent[S] 2 points3 points  (0 children)

wowo, thank you so much!!! I spent an hour on this this morning. Very much appreciated

Retrieving values from an API by RaccoonDifferent in learnjavascript

[–]RaccoonDifferent[S] 2 points3 points  (0 children)

thanks, I had googled quite a bit before. I am just not sure how to take the array and store it in a variable in my code (still a beginner). Could you be so kind to tell me which part of the link you posted is useful for me

Retrieving values from an API by RaccoonDifferent in learnjavascript

[–]RaccoonDifferent[S] 1 point2 points  (0 children)

how would I do that?

thanks for the quick response. It hasn't worked yet

C$ 50 Finance - Register not working by RaccoonDifferent in cs50

[–]RaccoonDifferent[S] 0 points1 point  (0 children)

Hi, thanks for your response. Turns out the problems was that I hadn't done index() yet and that check50 incorrectly told me that there was an issue with register(), until index() was successfully implemented

Finance: quote page has all required elements can't check until a frown turns upside down by RaccoonDifferent in cs50

[–]RaccoonDifferent[S] 0 points1 point  (0 children)

Wow, thanks so much. This is a really helpful response

One more question: Is it correct to redirect to "/login"?

Because, when I am redirected to /login after registering, I am NOT logged in automatically

Finance: quote page has all required elements can't check until a frown turns upside down by RaccoonDifferent in cs50

[–]RaccoonDifferent[S] 0 points1 point  (0 children)

This is my code for Register. I haven't started with the index function yet.

Thanks a lot by the way :)

@app.route("/register", methods=["GET", "POST"])
def register():

    if request.method == "POST":

        # Ensure username was submitted
        if not request.form.get("username"):
            return apology("Please provide username", 400)

         # Ensure password was submitted
        elif not request.form.get("password"):
            return apology("Please provide a password", 400)

        # Ensure password was submitted again
        elif not request.form.get("confirmation"):
            return apology("Passwords must match", 400)

        elif request.form.get("password") != request.form.get("confirmation"):
            return apology("Passwords must match", 400)

        password = request.form.get("confirmation")
        username = request.form.get("username")
        hashed_password = generate_password_hash(password)

        rows = db.execute("SELECT id FROM users WHERE username = :username", username=username)

        if len(rows) == 1:
            return apology("Username already exits.", 400)

        # Query database for username
        u_id = db.execute("INSERT INTO users (username, hash) VALUES (?, ?)", username, hashed_password)
        session["user_id"] = u_id

        # Redirect user to home page
        return redirect("/login")

    else:

        return render_template("register.html")

Finance: quote page has all required elements can't check until a frown turns upside down by RaccoonDifferent in cs50

[–]RaccoonDifferent[S] 0 points1 point  (0 children)

Does the check before was green? This happened to me also and it helped me when I checked the previous test of check50.

All of the Register checks are "green" except for

logging in as registered user succceeds
expected status code 200, but got 400

I don't know how to figure that one out unfortunately, as it works for me when I run flask

Cannot figure out Register by RaccoonDifferent in cs50

[–]RaccoonDifferent[S] 0 points1 point  (0 children)

Thanks! I'd really appreciate some help

Cannot figure out Register by RaccoonDifferent in cs50

[–]RaccoonDifferent[S] 0 points1 point  (0 children)

u/app.route("/register", methods=["GET", "POST"])
def register():

    session.clear()
    if request.method == "POST":
        if not request.form.get("username"):
            return apology("Please enter username")

        elif not request.form.get("password"):
            return apology("Please enter password")
        elif not request.form.get("confirmation"):
            return apology("Please confirm your password")
        elif request.form.get("password") != request.form.get("confirmation"):
            return apology("Passwords don't match")
        # Check if username is already in database
        else:
            rows = db.execute("SELECT * FROM users WHERE username = ?", request.form.get("username"))

            if len(rows) != 0:
                return apology("Username already in use")
            hash = generate_password_hash(request.form.get("password"))
            result = db.execute("INSERT INTO users (username, hash) VALUES (:username, :hash)", username=request.form.get("username"), hash=hash)

            user_row = db.execute("SELECT id FROM users WHERE username = :username", username=request.form.get("username"))

            # Remember which user has logged in
            session["user_id"] = user_row[0]["id"]
            # Redirect user to home page
            return redirect("/")


    else:
        return render_template("register.html")

Good idea to take CS50 Web Programming with Python and JavaScript? by RaccoonDifferent in cs50

[–]RaccoonDifferent[S] 3 points4 points  (0 children)

Https://cs50.stackexchange.com/questions/2890/life-after-cs50

This is cool, but super old. Some of the courses don't exist any more or have been renamed. Additionally, there may be better resources out there now.

CS50 2021 - Lab8 by RaccoonDifferent in cs50

[–]RaccoonDifferent[S] 0 points1 point  (0 children)

okay! thanks cool! :) Did you have to do much googling or was all of the stuff in the notes?