1

I create both grpc server and client. But I'm new to Node/TS and don't know how to save the respone in the callback function.

function read(path:string): string {
    logger.info(`reading ${path}`);
    var request:FileRequest = new FileRequest();
    request.setPath(path);
    grpc_client.read(request, (error: ServiceError | null, response: FileResponse) => {
        if (error !== null)
            throw new Error(`reading failed, error message : ${error.message}`);
        return response.getContent_asB64();        
    });
    return response.getContent_asB64();
}

If anyone can help me, thanks a lot!

Save the response in the callback function and return it.

0 Answers0