Javascript 获取xhr.js:184获取http://localhost:8600/user-service/userbyid/[object%20Object]400甚至url是否正确?

Javascript 获取xhr.js:184获取http://localhost:8600/user-service/userbyid/[object%20Object]400甚至url是否正确?,javascript,reactjs,spring,spring-mvc,Javascript,Reactjs,Spring,Spring Mvc,获取xhr.js:184获取http://localhost:8600/user-服务/userbyid/[object%20Object]400用于(“http://localhost:8600/user-service/userbyid/“+{used})其中used是分配给props值的变量? 任何我能够在我的console.log中打印“used”值的方法都是正确的,即使在我使用postman获取它时,也会给我输出。那么为什么这个反应部分没有给出输出呢 import axios from

获取xhr.js:184获取http://localhost:8600/user-服务/userbyid/[object%20Object]400用于(“http://localhost:8600/user-service/userbyid/“+{used})其中used是分配给props值的变量? 任何我能够在我的console.log中打印“used”值的方法都是正确的,即使在我使用postman获取它时,也会给我输出。那么为什么这个反应部分没有给出输出呢

import axios from "axios";
import { Link } from "react-router-dom";
import React, { useEffect, useState } from "react";
import { useHistory, useParams } from "react-router-dom";
import { withStyles, makeStyles } from '@material-ui/core/styles';
import Table from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
import TableContainer from '@material-ui/core/TableContainer';
import TableHead from '@material-ui/core/TableHead';
import TableRow from '@material-ui/core/TableRow';
import Paper from '@material-ui/core/Paper';
import Button from '@material-ui/core/Button';


const StyledTableCell = withStyles((theme) => ({
    head: {
      backgroundColor: theme.palette.common.black,
      color: theme.palette.common.white,
    },
    body: {
      fontSize: 14,
    },
  }))(TableCell);
  
  const StyledTableRow = withStyles((theme) => ({
    root: {
      '&:nth-of-type(odd)': {
        backgroundColor: theme.palette.action.hover,
      },
    },
  }))(TableRow);


  const useStyles = makeStyles({
    table: {
      minWidth: 350,
    },
  });

export default function Dashboard(props) {
   console.log(props);
   let used = props;
    const classes = useStyles();
  const { id } = useParams();
  const [user, setUser] = useState({
    name: "",
    email: "",
    userId: 0,
  });

  const [exams, setExam] = useState([]);
  useEffect(() => {
    getExams();
  }, []);

  const getExams = async () => {
    const response = await axios.get(
      "http://localhost:8500/exam-service/showexam"
    );
    setExam(response.data);
  };

  const { userId, name, email } = user;

  const loadUser = async () => {
    const result = await axios.get(
      "http://localhost:8600/user-service/userbyid/" + {used} 
    );
    console.log(result.data);
    setUser(result.data);
  };


  useEffect(() => {
    loadUser();
  }, []);

  return (
    <div align="center">
        <br/>
        <hr/>
        <br/>
      <h2>ATTEMPT EXAMS</h2>
      <TableContainer style={{width: 350}} component={Paper}>
        <Table style={{ width: 300 }} className={classes.table} aria-label="customized table">
          <TableHead>
            <TableRow>
              <StyledTableCell align="left">TOPIC</StyledTableCell>
              <StyledTableCell align="Right">Action</StyledTableCell>
            </TableRow>
          </TableHead>
          <TableBody>
          
                   {exams.map((exam, index) => (
              <StyledTableRow>
                <StyledTableCell component="th" scope="row">
                {exam.title}
                </StyledTableCell>
                
                <StyledTableCell align="right">
                <Link class="btn btn-primary mr-5" to={`/attemptexam/${used}/exam/${exam.qBankId}`} >Attempt</Link>
                </StyledTableCell>
                </StyledTableRow>
                ))}
                </TableBody>
                  </Table>
                </TableContainer>
     
        
      
    </div>
  );
}
从“axios”导入axios;
从“react router dom”导入{Link};
从“React”导入React,{useffect,useState};
从“react router dom”导入{useHistory,useParams};
从“@material ui/core/styles”导入{withStyles,makeStyles}”;
从“@material ui/core/Table”导入表格;
从“@material ui/core/TableBody”导入表体;
从“@material ui/core/TableCell”导入TableCell;
从“@material ui/core/TableContainer”导入TableContainer;
从“@material ui/core/TableHead”导入表头;
从“@material ui/core/TableRow”导入TableRow;
从“@material ui/core/Paper”导入纸张;
从“@material ui/core/Button”导入按钮;
const StyledTableCell=带有样式((主题)=>({
负责人:{
背景色:theme.palette.common.black,
颜色:theme.palette.common.white,
},
正文:{
尺寸:14,
},
}))(表细胞);
const StyledTableRow=带有样式((主题)=>({
根目录:{
“&:n类型(奇数)”:{
背景色:theme.palete.action.hover,
},
},
}))(表行);
const useStyles=makeStyles({
表:{
最小宽度:350,
},
});
导出默认功能仪表板(道具){
控制台日志(道具);
让我们使用=道具;
const classes=useStyles();
const{id}=useParams();
const[user,setUser]=useState({
姓名:“,
电邮:“,
用户ID:0,
});
const[tests,setExam]=useState([]);
useffect(()=>{
获取考试();
}, []);
const gettests=async()=>{
const response=等待axios.get(
"http://localhost:8500/exam-服务/展示考试”
);
setExam(response.data);
};
const{userId,name,email}=user;
const loadUser=async()=>{
const result=等待axios.get(
"http://localhost:8600/user-服务/userbyid/“+{used}
);
console.log(result.data);
setUser(结果数据);
};
useffect(()=>{
loadUser();
}, []);
返回(



试考 话题 行动 {tests.map((考试,索引)=>( {考试题目} 企图 ))} ); }
http://localhost:8600/user-服务/userbyid/endpointexpect?用户ID?我这样问是因为
used
似乎是一个JSON对象。在本例中,我怀疑端点是否希望URL中有一个JSON对象。