[docs] Updates todo app docs (#677)

* Changed HttpError from 403 to 401
This commit is contained in:
h4r1337 2022-07-26 23:34:06 +05:30 committed by GitHub
parent 8bae408298
commit 0de9997198
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -220,7 +220,7 @@ Next, let's update the queries and actions to forbid access to non-authenticated
import HttpError from '@wasp/core/HttpError.js'
export const getTasks = async (args, context) => {
if (!context.user) { throw new HttpError(403) }
if (!context.user) { throw new HttpError(401) }
return context.entities.Task.findMany(
{ where: { user: { id: context.user.id } } }
)
@ -231,7 +231,7 @@ export const getTasks = async (args, context) => {
import HttpError from '@wasp/core/HttpError.js'
export const createTask = async ({ description }, context) => {
if (!context.user) { throw new HttpError(403) }
if (!context.user) { throw new HttpError(401) }
return context.entities.Task.create({
data: {
description,
@ -241,7 +241,7 @@ export const createTask = async ({ description }, context) => {
}
export const updateTask = async ({ taskId, data }, context) => {
if (!context.user) { throw new HttpError(403) }
if (!context.user) { throw new HttpError(401) }
return context.entities.Task.updateMany({
where: { id: taskId, user: { id: context.user.id } },
data: { isDone: data.isDone }