【发布时间】:2021-10-25 16:51:34
【问题描述】:
我有 2 个用于读取数据的 Get API I。我使用的第一个 API 是读取学生详细信息。在这个学生详细信息中,我需要从第二个 API 读取 ID 并在第一个 API 中显示数据
第一个 API 是 getDetails 第二个 API 是 getClass
我想在获得类名后将e.student_class_id 传递给getClass 我将在getDetails 处传回类名
const getDetails= (infoID) =>
{
axios.get(`${apiInfo}student/getDetails?student_id=${infoID}`)
.then(function (response) {
if(response.data.status == 'success')
{
e = response.data.result;
//passing this e.student_class_id;
$('#tabClassName').html(`<div class="col-xl-12 row">
<div class="col-xl-6">
<h6>Class details</h6>
<p>Class :<span class="item"> //and pass the class name here ? </span></p>
</div>
</div>
`);
}
});
}
const getClass= () =>
{
axios.get(`${apiInfo}getClass`)
.then(function (res) {
if(res.data.status == 'success')
{
res.data.result.map((e) =>{
if(e.id == 'how do I pass it the e.student_class_id here ?'){
// return``;
console.log(e.class_name);
}
});
}
});
}
【问题讨论】:
-
你可以使用会话
-
会话?我如何通过 session 传递它?
标签: javascript jquery arrays axios get