我想在第二个访问this
然后从fetch中访问。
但它一直说:TypeError:_this2.login
不是函数
fbAuth() {
LoginManager.logInWithReadPermissions(['public_profile']).then(function(res) {
if (res.isCancelled) {
console.info('cancelled');
} else {
console.info('login success');
AccessToken.getCurrentAccessToken().then((data) => {
let req = new GraphRequest('/me', {
httpMethod: 'GET',
version: 'v2.5',
parameters: {
'fields': {
'string' : 'id,email,name'
}
}
}, (err, res) => {
const data = new FormData();
data.append('facebook_user_id', res.id);
data.append('email', res.email);
data.append('name', res.name);
fetch('xxxxxxxxxxx', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: data,
})
.then((response) => response.json())
.then((responseJson) => {
this.login(responseJson);
})
.catch((error) => {
console.error(error);
alert('Something went wrong. Please try again, if the problem persists contact the @lacarte service desk');
});
});
new GraphRequestManager().addRequest(req).start();
});
}
}, function(error) {
console.error(error);
});
}
答案 0 :(得分:4)
假设this
应该是this
同样具有fbAuth
方法的LoginManager.logInWithReadPermissions(['public_profile']).then(res => {
...
});
,您还应该为第一个承诺使用箭头函数声明:
public class App implements Serializable {
public static void main(String[] args) {
SparkSession sparkSession = SparkSession.builder()
.appName("SparkSQL")
.master("local")
.getOrCreate();
Dataset<Row> df = sparkSession.createDataFrame(
Arrays.asList(new Person("panfei",27)),Person.class);
System.out.println(df.rdd().count());
}
}