Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
My id of an hyperlink tag keeps displaying as text on the browser in Svelte

I've been trying to make a web app wiki using my knowledge of Restful APIs and svelte and I've come across a problem where I gave the hyperlink tags the id of the id of each object in the db, it works but the problem is that it keeps on displaying the id of the hyperlink tag() as text in the browser. How can I fix this?

Here is a visual representation of the result:

Here is a visual representation of the result

Here's the code:

<script>
import { onMount } from 'svelte';
import { each } from 'svelte/internal';
import { store } from '$lib/store';

let articles = [];
onMount(async () => {
    const response = await fetch('http://localhost:5000/articles');
    const data = await response.json();
    articles = data;
})

</script>

<div class="container">
    {#each articles as article}
        <a href="/articles/article/{article._id}" id={article._id}>
             {article.title}
            <hr>
        </a>
        {$store = article._id}
    {/each}
</div>

<style>
    a {
        text-decoration: none;
        color: rgb(223, 209, 209);
        font-weight: bold;
        font-size: 1.5rem;
    }

    a::hover {
        text-decoration: underline;
    }

    div {
        margin-top: 90px;
        text-align: center;
    }
</style>

I really need help T_T

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

To not display the ID, you need to remove this line:

{$store = article._id}

This is assigning to the store and returning the value, which renders the ID text. This isn't something that's normal to do in Svelte code. Usually, you update the data in your script block and render it in your template -- your template shouldn't have side effects on your data.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!