第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何從randomuser API獲取用戶的用戶詳細(xì)信息?

如何從randomuser API獲取用戶的用戶詳細(xì)信息?

在 React 作業(yè)中,我嘗試從 randomuser.me API 獲取用戶詳細(xì)信息并將其顯示在另一個(gè)組件上。除了無(wú)法從其 id 獲取用戶詳細(xì)信息之外,一切都已完成管理面板.js<TableBody>          {results.map((person) => (            <TableRow key={person.id.value}>                <TableCell component="th" scope="row">{person.name.first}</TableCell>                <TableCell align="right">{person.name.last}</TableCell>                <TableCell align="center">{person.location.street.name + ',' + person.location.street.number + ',' + person.location.state + ',' + person.location.country  }</TableCell>                <TableCell align="right"><img src={person.picture.thumbnail} /></TableCell>                <TableCell align="center">{person.email}</TableCell>                <TableCell align="right">{person.dob.date}</TableCell>                <TableCell align="right">                <Button variant="contained" color="primary" >                    <Link style={{color:'white'}} to={`/user-detail/${person.login.uuid}`}>View Details</Link>                </Button>                </TableCell>            </TableRow>          ))}</TableBody>單擊鏈接后,它會(huì)重定向到另一個(gè)頁(yè)面,如下所示用戶詳細(xì)信息import React, {useEffect} from 'react'import { useParams } from 'react-router-dom';export const UserDetail = () => {    const {userid} = useParams()    useEffect(() => {        fetch(`/user-detail/${userid}`).then(res=>res.json()).then(result=> {            console.log(result)        })    }, [])    return (        <div>                    </div>    )}Bu,當(dāng)控制臺(tái)日志顯示此錯(cuò)誤“未捕獲(承諾中)SyntaxError:位置 0 處的 JSON 中出現(xiàn)意外標(biāo)記 <”時(shí)我犯了什么錯(cuò)誤?
查看完整描述

2 回答

?
holdtom

TA貢獻(xiàn)1805條經(jīng)驗(yàn) 獲得超10個(gè)贊

獲取網(wǎng)址

fetch (`https://randomuser.me/api/?seed=${seed}`). then (d=>d.json()).then(e=>console.log(e))

其中種子是一個(gè)像這樣的字符串

const seed ="fea8be3e64777240"


查看完整回答
反對(duì) 回復(fù) 2024-01-18
?
梵蒂岡之花

TA貢獻(xiàn)1900條經(jīng)驗(yàn) 獲得超5個(gè)贊

如果您有興趣生成帶有詳細(xì)信息的隨機(jī)用戶,可以使用另一個(gè)免費(fèi) API。

API:https ://wirespec.dev/Wirespec/projects/apis/Stackoverflow/apis/getUserDetails

端點(diǎn):https://api.wirespec.dev/wirespec/stackoverflow/getuserdetails? id=100

Wirespec 允許您創(chuàng)建最多 100 萬(wàn)個(gè)隨機(jī)用戶(包括頭像)。檢查一下:

https://wirespec.dev


查看完整回答
反對(duì) 回復(fù) 2024-01-18
?
MM們

TA貢獻(xiàn)1886條經(jīng)驗(yàn) 獲得超2個(gè)贊

你需要使用狀態(tài)來(lái)獲取結(jié)果


import React, {useState, useEffect} from 'react'

import { useParams } from 'react-router-dom';



export const UserDetail = () => {

    const {userid} = useParams()

    const [result, setResult] = useState([]); 

    useEffect(() => {

        fetch(`/user-detail/${userid}`).then(res=>res.json()).then(result=> {

            console.log(result)

            setResult(result);

        })


    }, [])

    return (

        <div>

            

        </div>

    )

}


查看完整回答
反對(duì) 回復(fù) 2024-01-18
  • 2 回答
  • 0 關(guān)注
  • 253 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)