Tạo url từ thông tin đọc từ api

Tạo url từ thông tin đọc từ api

Đọc thông tin từ api tạo url 

'use client'
import {useEffect, useState} from "react";
import axios from "axios";
export default function  Home() {
    const [data, setData] = useState([]);
    const [isLoading, setLoading] = useState(true);
     useEffect( ()=>{
        const res = axios.get('https://my-json-server.typicode.com/typicode/demo/posts');
         res.then((response)=>{
            setData(response.data);
            setLoading(false);
            console.log(response.data);
        });
    },[])
    if (isLoading) return <p>Loading...</p>
    return (
        <main className="flex  flex-col ">
            {data && data.map((item,index) =>(
                <a href={`http://localhost:3000/users/${item['id']}`}>
                    <span key={index}>{item['title']}</span>
                </a>
                )
            )}
        </main>
    )
}