Skip to content
  • Unlock Pro
  • Log in with GitHub
Profile
OverviewSolutions
3
Comments
4

lloydjohnlandeza

@lloydjohnlandeza150 points

I’m a mysterious individual who has yet to fill out my bio. One thing’s for certain: I love writing front-end code!

I’m currently learning...

Flutter

Latest solutions

  • NextJS, Typescript and tailwind

    #next#react#typescript#tailwind-css

    lloydjohnlandeza•150
    Submitted about 2 years ago

    0 comments
  • Vue 3 and TailwindCSS

    #tailwind-css#typescript#vite#vue#pinia

    lloydjohnlandeza•150
    Submitted over 2 years ago

    0 comments
  • Vue 3, Typescript, Pinia for state management and plain old css for UI

    #pinia#sass/scss#typescript#vue

    lloydjohnlandeza•150
    Submitted over 2 years ago

    0 comments

Latest comments

  • Nicolas De La Fuente•140
    @NicoDeLaFuente
    Submitted about 2 years ago

    Rest Country Api with color Theme switcher

    #react
    1
    lloydjohnlandeza•150
    @lloydjohnlandeza
    Posted about 2 years ago

    One solution to make the border links work, is by fetching the official name of the border country from the API. You can use the following API endpoint to retrieve the official name based on the border code you pass: https://restcountries.com/v3.1/alpha/${border}?fields=name

    Since you already have your BorderButton component in a separate file, you can perform the fetch operation there. Here's an example implementation:

    import { Link } from "react-router-dom"
    import { useEffect, useState } from "react";
    
    const BorderButton = ({border, borderCountryHandler}) => {
          const [borderName, setBorderName] = useState('')
          useEffect(() => {
            fetchName()
          }, [])
          const fetchName = () => {
              const fetching = fetch(`https://restcountries.com/v3.1/alpha/${border}?fields=name`)
              fetching.then( res => res.json())
                      .then(data => setBorderName(data?.name?.official))
          }
    
        return <Link to={`/detail/${borderName}`}  className="btn-border btn" id={border}>{border}</Link>
    }
    
    export default BorderButton
    

    I hope this clarification helps you resolve the issue with the border links in the country detail view. Let me know if you have any further questions!

    Marked as helpful
  • Mustapha•90
    @notMoustee
    Submitted about 2 years ago

    rest-countries-api-with-color-theme-switcher

    #fetch
    2
    lloydjohnlandeza•150
    @lloydjohnlandeza
    Posted about 2 years ago

    Nice pure javascript solution! It's nostalgic to see a javascript code without any framework/libraries.

    Anyway to fix your issue on the border toggle you should check if the body has a class "dark-mode" before generating the html template for borderCountries.

    The solution for it is below but I suggest you try doing it first before checking it.

    • Spoiler Alert
    • Spoiler Alert
    • Spoiler Alert
    • Spoiler Alert
    const isInDarkMode = document.body.classList.contains('dark-mode')
    const borderDarkMode = isInDarkMode ? 'border-dark' : '' 
    borderCountries = borders.length > 0 ? borders.map((border) => 
    `<span class="border ${borderDarkMode}">${border}</span>`).join('') : 'None' 
    
    Marked as helpful
  • P
    Nitya Gulati•665
    @nityagulati
    Submitted about 2 years ago

    Rest Countries API - Vue

    #vue#vuex
    1
    lloydjohnlandeza•150
    @lloydjohnlandeza
    Posted about 2 years ago

    Well done doing this challenged! Regarding the issue you mentioned with losing route params on refreshing the Country Info page, it's actually a server-side problem with SPA (Single Page Applications) and not directly related to your code. Since you're using GitHub Pages (github.io), your options for resolving this issue are somewhat limited.

    The first and easiest option is to change your router's history mode to use web hash. You can achieve this by modifying your router setup as follows:

    const router = createRouter({
        mode: 'history',
        history: createWebHashHistory(), // previous value: createWebHistory()
        routes,
    });
    

    By adding a hash at the beginning of your URLs, this approach ensures that your SPA always loads correctly.

    The second option is more complex, requiring you to update your 404.html file to load the code from index.html. This way, even when encountering a 404 error, your SPA's code will still be loaded properly.

    The third option involves using Netlify instead of GitHub Pages (don't worry netlify is free as well). With Netlify, you can easily resolve this issue by utilizing redirects. You can find more information about using redirects with Netlify here.

  • Toni•420
    @ToenSh
    Submitted over 2 years ago

    Interactive Comment Section

    #react#vite#tailwind-css
    2
    lloydjohnlandeza•150
    @lloydjohnlandeza
    Posted over 2 years ago

    Nice solution! I solved the limiting of upvote/downvote by adding an upVoted and downVoted boolean flag to the comment object. You can check those flag before changing the score. But you can make it a step further by making that boolean into an array of username that upVoted or downVoted the comment to make it work with multiple users!

Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub