Skip to content

Commit 7058860

Browse files
authored
fix form actions chapter (sveltejs#543)
Co-authored-by: Rich Harris <[email protected]>
1 parent 4bbafc4 commit 7058860

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

content/tutorial/03-sveltekit/06-forms/01-the-form-element/app-a/src/routes/+page.server.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ export function load({ cookies }) {
44
const id = cookies.get('userid');
55

66
if (!id) {
7-
cookies.set('userid', crypto.randomUUID(), { path: '/' });
7+
id = crypto.randomUUID();
8+
cookies.set('userid', id, { path: '/' });
89
}
910

1011
return {
11-
todos: db.getTodos(id) ?? []
12+
todos: db.getTodos(id)
1213
};
1314
}

content/tutorial/03-sveltekit/06-forms/01-the-form-element/app-b/src/routes/+page.server.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ export function load({ cookies }) {
44
const id = cookies.get('userid');
55

66
if (!id) {
7-
cookies.set('userid', crypto.randomUUID(), { path: '/' });
7+
id = crypto.randomUUID();
8+
cookies.set('userid', id, { path: '/' });
89
}
910

1011
return {
11-
todos: db.getTodos(id) ?? []
12+
todos: db.getTodos(id)
1213
};
1314
}
1415

content/tutorial/03-sveltekit/06-forms/02-named-form-actions/app-b/src/routes/+page.server.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ export function load({ cookies }) {
44
const id = cookies.get('userid');
55

66
if (!id) {
7-
cookies.set('userid', crypto.randomUUID(), { path: '/' });
7+
id = crypto.randomUUID();
8+
cookies.set('userid', id, { path: '/' });
89
}
910

1011
return {
11-
todos: db.getTodos(id) ?? []
12+
todos: db.getTodos(id)
1213
};
1314
}
1415

content/tutorial/03-sveltekit/06-forms/03-form-validation/app-b/src/routes/+page.server.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ export function load({ cookies }) {
55
const id = cookies.get('userid');
66

77
if (!id) {
8-
cookies.set('userid', crypto.randomUUID(), { path: '/' });
8+
id = crypto.randomUUID();
9+
cookies.set('userid', id, { path: '/' });
910
}
1011

1112
return {
12-
todos: db.getTodos(id) ?? []
13+
todos: db.getTodos(id)
1314
};
1415
}
1516

content/tutorial/03-sveltekit/06-forms/05-customizing-use-enhance/app-b/src/routes/+page.server.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ export function load({ cookies }) {
55
const id = cookies.get('userid');
66

77
if (!id) {
8-
cookies.set('userid', crypto.randomUUID(), { path: '/' });
8+
id = crypto.randomUUID();
9+
cookies.set('userid', id, { path: '/' });
910
}
1011

1112
return {
12-
todos: db.getTodos(id) ?? []
13+
todos: db.getTodos(id)
1314
};
1415
}
1516

0 commit comments

Comments
 (0)