How to return DataFrame when it comes from an async function?

Hello everyone, I’m making a datasource plugin, and I have a function
async testFunc()
that returns a
Promise<DataFrame>
as this function is where a web request is made, it is async.

I’m trying to convert this DataFrame to a DataQueryResponse, and then have that be the return value for the query function within Datasource.ts. I know this is hardcoding it and bad practice, but im not sure how to do it properly and at this point I just want an output.

This is as far as I got, with the error message on the second to last line saying

  • Argument of type ‘DataQueryResponse’ is not assignable to parameter of type ‘(resolve: (value: DataQueryResponse | PromiseLike) => void, reject: (reason?: any) => void) => void’.

  • Type ‘DataQueryResponse’ provides no match for the signature ‘(resolve: (value: DataQueryResponse | PromiseLike) => void, reject: (reason?: any) => void): void’.

  query(options: QueryRequest): Promise<DataQueryResponse> {

    let dataframe = Observable.create(testFunc());
    const dqr: DataQueryResponse = {
      data: dataframe,
    };
    let retval: Promise<DataQueryResponse> = new Promise(dqr);
    return retval;

I don’t understand the type problems, and I’m not sure if this is just an async problem or if I’m approaching this topic incorrectly. Any help is much appreciated!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.