OliverL
OliverL
WWasp-lang
Created by Dhruw Mistry on 10/20/2023 in #🙋questions
Learning Resources for beginners getting started
They have a free curriculum of interactive tutorials for all you need from zero to hero
4 replies
WWasp-lang
Created by Dhruw Mistry on 10/20/2023 in #🙋questions
Learning Resources for beginners getting started
If you are really new I recommend learning the basics first. A good place to do so is freecodecamp.org
4 replies
WWasp-lang
Created by OliverL on 10/19/2023 in #🙋questions
Shared function generates CORS error
Nice clarification
16 replies
WWasp-lang
Created by OliverL on 10/19/2023 in #🙋questions
Shared function generates CORS error
Yes, changing the import to shared/taskChecker.js fixed that! Thank you and sorry for the newbie question 🙏
16 replies
WWasp-lang
Created by OliverL on 10/19/2023 in #🙋questions
Shared function generates CORS error
import { Task } from '@wasp/entities'
import { GetTasks } from '@wasp/queries/types'

export const getTasks: GetTasks<void, Task[]> = async (args, context) => {
return context.entities.Task.findMany({
orderBy: { id: 'asc' },
})
}
import { Task } from '@wasp/entities'
import { GetTasks } from '@wasp/queries/types'

export const getTasks: GetTasks<void, Task[]> = async (args, context) => {
return context.entities.Task.findMany({
orderBy: { id: 'asc' },
})
}
16 replies
WWasp-lang
Created by OliverL on 10/19/2023 in #🙋questions
Shared function generates CORS error
The request that is causing the error is the query that gets the tasks
16 replies
WWasp-lang
Created by OliverL on 10/19/2023 in #🙋questions
Shared function generates CORS error
This is shared/taskChecker.ts
export function checkTask(task: String): { valid: Boolean, message: String } {
if (task.length > 10) {
return { valid: false, message: "Task is too long" }
}
return { valid: true, message: "" }
}
export function checkTask(task: String): { valid: Boolean, message: String } {
if (task.length > 10) {
return { valid: false, message: "Task is too long" }
}
return { valid: true, message: "" }
}
And this is the server/actions.ts
import { Task } from '@wasp/entities'
import { CreateTask } from '@wasp/actions/types'
import { checkTask } from '@wasp/shared/taskChecker'

type CreateTaskPayload = Pick<Task, 'text'>

export const createTask: CreateTask<CreateTaskPayload, Task> = async (
args,
context
) => {
// If I comment the next line, the CORS error is gone
const { valid, message } = checkTask(args.text)
// The idea is to do something with the data returned by the function

return context.entities.Task.create({
data: { text: args.text },
})
}
import { Task } from '@wasp/entities'
import { CreateTask } from '@wasp/actions/types'
import { checkTask } from '@wasp/shared/taskChecker'

type CreateTaskPayload = Pick<Task, 'text'>

export const createTask: CreateTask<CreateTaskPayload, Task> = async (
args,
context
) => {
// If I comment the next line, the CORS error is gone
const { valid, message } = checkTask(args.text)
// The idea is to do something with the data returned by the function

return context.entities.Task.create({
data: { text: args.text },
})
}
16 replies