嘿,我尝试在获取数据后重定向到另一个,但我能够重定向,但是当我在结果页面中使用COPY --chown=1000:1000 environment.yml requirements.txt postBuild ./
时,它在控制台中的显示为this.props.location.state
,这是我的所有代码,请问这段代码中的错误在哪里。
Search.js
[object Object],[object Object],[object Object],[object Object],[object Object]
在async handleSubmit(e) {
let authToken = localStorage.getItem("Token");
try {
const from = e.target.elements.from.value;
const to = e.target.elements.to.value;
const selections = [...e.target.elements.selectOptions.options].filter(
opt => opt.selected
);
const selectedValues = selections.map(opt => opt.value);
const selectedString = selectedValues.join(",");
e.preventDefault();
const res = await fetch(
`http://localhost:8000/api/1/deliveries/report/?date__lte=${to}&date__gte=${from}&user=${selectedString}`,
{
method: "GET",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
Authorization: "Bearer " + JSON.parse(authToken)
}
}
);
const movie = await res.json();
console.log(movie);
this.setState({
movie
});
// this.props.history.push("/driverreport");
this.props.history.push({
pathname: "/driverreport",
state: movie
});
} catch (e) {
console.log(e);
}
}
中,我只是在控制台中检查数据,但是我正在获取这样的数据`
result.js
result.js
答案 0 :(得分:-1)
请参阅此link,以获取更多详细信息。
您可以通过以下示例访问数据:-
let data = {
name:'John',
id:123,
movie:"ABC"
}
// Using "+" in console.log() it shows Don: [object Object]
console.log("Don: " + data);
//But you can access it by :-
console.log("Don: " + data.movie);
// Using "," in console.log() it shows entire data object with key value pair
console.log("Don: " , data);