import Axios , { AxiosResponse } from "axios" ; interface Artifact { path : string ; pretty_path : string ; node_index : number ; url : string ; } export const getArtifactUrl = async ( url , targetPath ) : Promise < string > => { return await Axios . get ( url ) . then ( ( { data } ) => data ) . then ( ( artifacts ) => artifacts . filter ( ( artifact ) => artifact . path . includes ( targetPath ) ) [ 0 ] ) . then ( ( artifact ) : string => { if ( ! artifact ) { throw new Error ( `Cannot find any artifacts with: ${ targetPath }` ) ; } return artifact . url ; } ) . catch ( error => { console . log ( error ) ; return "" ; } ) ; } ;