我对打字稿有点绿,所以不确定我在这里做的不是什么。我有一个班级retriver.ts
:
import * as rets from 'rets-client';
export class retsRetrv {
results: any;
constructor(
private auth: any,
private options: any
) {
rets.getAutoLogoutClient(auth, (client) => {
client.search.query(options.opt1, options.opt2, options.opt3)
.then(data => {
return this.results = data.results;
});
});
}
}
然后我需要在我的index.ts中使用多次调用,以便我可以在响应中使用其他一些类,所以我正在尝试这个:
// import rets retriver
import { retsRetrv } from './retriever/retriver';
// import auths
import { norris } from './norris/auth/norris';
import { mcars } from './mcars/auth/mcars';
// run norris
new retsRetrv(norris.login, norris.options).then(data => {
console.log(data);
});
//run mcars
mcars.options.opt2.forEach(type => {
// console.log(type.type);
let options = {
opt1: mcars.options.opt1,
opt2: type.type,
opt3: mcars.options.opt3,
}
new retsRetrv(mcars.login, options);
});
现在只处理norris实例以使其正常工作,但当我尝试.then()
时,TS linting告诉我property then does not exist on type retsRetrv