Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

std/permissions/mod.ts>grantOrThrow

The Deno Standard Library
Go to Latest
function grantOrThrow
import { grantOrThrow } from "https://deno.land/std@0.222.1/permissions/mod.ts";

Attempts to grant a set of permissions or rejects.

     import { grantOrThrow } from "https://deno.land/std@0.222.1/permissions/mod.ts";
     await grantOrThrow({ name: "env" }, { name: "net" });

If the permission can be prompted for, the function will attempt to prompt. If any of the permissions are denied, the function will reject for the first permission that is denied. If all permissions are granted, the function will resolve.

Returns

Promise<void>

Attempts to grant a set of permissions or rejects.

     import { grantOrThrow } from "https://deno.land/std@0.222.1/permissions/mod.ts";
     await grantOrThrow([{ name: "env" }, { name: "net" }]);

If the permission can be prompted for, the function will attempt to prompt. If any of the permissions are denied, the function will reject mentioning the the denied permissions. If all permissions are granted, the function will resolve.

Returns

Promise<void>