mirror of
				https://github.com/mealie-recipes/mealie.git
				synced 2025-11-03 18:53:17 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			21 lines
		
	
	
		
			494 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			494 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
import { BaseAPI } from "../_base";
 | 
						|
import { FileTokenResponse } from "~/types/api-types/response";
 | 
						|
 | 
						|
const prefix = "/api";
 | 
						|
 | 
						|
export class UtilsAPI extends BaseAPI {
 | 
						|
  async download(url: string) {
 | 
						|
    const { response } = await this.requests.get<FileTokenResponse>(url);
 | 
						|
 | 
						|
    if (!response) {
 | 
						|
      return;
 | 
						|
    }
 | 
						|
 | 
						|
    const token: string = response.data.fileToken;
 | 
						|
 | 
						|
    const tokenURL = prefix + "/utils/download?token=" + token;
 | 
						|
    window.open(tokenURL, "_blank");
 | 
						|
    return response;
 | 
						|
  }
 | 
						|
}
 |