我在另一个方法中调用一个方法,当我这样做时,它没有找到我正在调用的方法,我不明白该怎么做,所以在调用函数时它知道它在方法之外。
export default class Main extends Component {
constructor(props) {
super(props);
this.state = {
user: null,
info: {}
}
this.ConsumirGraph = this.ConsumirGraph.bind(this)
}
ConsumirGraph = (token, send) => {
var info = new Object();
this.state.info = info
$.ajax({
url: send,
type: "GET",
headers: {
"Authorization": "Bearer " + token,
},
success: function(data) {
debugger;
if (data["@odata.context"] === "https://graph.microsoft.com/v1.0/$metadata#users(department)/$entity") {
info.obj = data;
console.log(info)
} else if (data["@odata.context"] === "https://graph.microsoft.com/v1.0/$metadata#directoryObjects/$entity") {
info.jefe = data;
console.log(info)
} else {
info.user = data;
console.log(info)
}
},
error: function(error) {
debugger;
console.log(error);
}
});
}
graphi() {
authContext.acquireToken(adalConfig.endpoints.graphApiUri, function(error, token) {
if (error) {
if (adalConfig.popUp) {
authContext.acquireTokenPopup(adalConfig.endpoints.graphApiUri, null, null, function(errorDesc, token, error) {});
console.log("ADAL error occurred: " + error);
return;
} else {
authContext.acquireTokenRedirect(adalConfig.endpoints.graphApiUri, null, null);
}
} else {
console.log('va bien de momentp')
var headers = new Headers();
var bearer = "Bearer " + token;
headers.append("Authorization", bearer);
var options = {
method: "GET",
headers: headers
};
var graphEndpoint = "https://graph.microsoft.com/v1.0/me";
let jefe = "https://graph.microsoft.com/v1.0/me/manager";
let getMemberGroups = "https://graph.microsoft.com/v1.0/me/?$select=department";
fetch(graphEndpoint, options)
.then((response) => {
this.ConsumirGraph(token, getMemberGroups);
this.ConsumirGraph(token, jefe);
this.ConsumirGraph(token, graphEndpoint)
})
}
});
}
错误:未处理的拒绝(TypeError):无法读取未定义的属性“ConsumirGraph”