Skip to content

Commit

Permalink
Fix examples in CookieStore interface (#31001)
Browse files Browse the repository at this point in the history
  • Loading branch information
skyclouds2001 authored Dec 15, 2023
1 parent 93c9f99 commit 2a13a5b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions files/en-us/web/api/cookiestore/delete/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ A {{jsxref("Promise")}} that resolves with {{jsxref("undefined")}} when deletion

## Examples

In this example a cookie is deleted by passing the name to the `delete()` method.
In this example, a cookie is deleted by passing the name to the `delete()` method.

```js
let result = cookieStore.delete("cookie1");
const result = cookieStore.delete("cookie1");

console.log(result);
```

Expand Down
5 changes: 3 additions & 2 deletions files/en-us/web/api/cookiestore/get/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ A {{jsxref("Promise")}} that resolves with an object representing the first cook

## Examples

In this example we return a cookie named "cookie1". If the cookie is found the result of the Promise is an object containing the details of a single cookie.
In this example, we return a cookie named "cookie1". If the cookie is found the result of the Promise is an object containing the details of a single cookie.

```js
let cookie = cookieStore.get("cookie1");
const cookie = await cookieStore.get("cookie1");

if (cookie) {
console.log(cookie);
} else {
Expand Down
7 changes: 4 additions & 3 deletions files/en-us/web/api/cookiestore/getall/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,12 @@ Each object contains the following properties:

## Examples

In this example we use `getAll()` with no parameters. This returns all of the cookies for this context as an array of objects.
In this example, we use `getAll()` with no parameters. This returns all of the cookies for this context as an array of objects.

```js
let cookies = await cookieStore.getAll();
if (cookies) {
const cookies = await cookieStore.getAll();

if (cookies.length > 0) {
console.log(cookies);
} else {
console.log("Cookie not found");
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/cookiestore/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The `CookieStore` is accessed via attributes in the global scope in a {{domxref(

## Examples

In this example we set a cookie and write to the console feedback as to whether the operation succeeded or failed.
In this example, we set a cookie and write to the console feedback as to whether the operation succeeded or failed.

```js
const day = 24 * 60 * 60 * 1000;
Expand Down
1 change: 1 addition & 0 deletions files/en-us/web/api/cookiestore/set/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ The following example sets a cookie by passing an object with `name`, `value`, `

```js
const day = 24 * 60 * 60 * 1000;

cookieStore.set({
name: "cookie1",
value: "cookie1-value",
Expand Down

0 comments on commit 2a13a5b

Please sign in to comment.