Killer🔪
Killer🔪
KPCKevin Powell - Community
Created by Killer🔪 on 2/7/2024 in #back-end
JSON.parse unexpected error
I dont know what changed but now I am getting the CORS error and not the earlier one
14 replies
KPCKevin Powell - Community
Created by Killer🔪 on 2/7/2024 in #back-end
JSON.parse unexpected error
Same thing
14 replies
KPCKevin Powell - Community
Created by Killer🔪 on 2/7/2024 in #back-end
JSON.parse unexpected error
If I do console.log(res.body) it just shows that ReadableStream { locked: false }
14 replies
KPCKevin Powell - Community
Created by Killer🔪 on 2/7/2024 in #back-end
JSON.parse unexpected error
Response { type: "basic", url: "http://localhost:5173/api/workouts", redirected: false, status: 200, ok: true, statusText: "OK", headers: Headers(6), body: ReadableStream, bodyUsed: false }
​
body: ReadableStream { locked: true }
​​
locked: true
​​
<prototype>: ReadableStreamPrototype { cancel: cancel(), getReader: getReader(), pipeThrough: pipeThrough(), … }
​
bodyUsed: true
​
headers: Headers(6) { "access-control-allow-origin" → "*", "cache-control" → "no-cache", "content-length" → "674", … }
​
ok: true
​
redirected: false
​
status: 200
​
statusText: "OK"
​
type: "basic"
​
url: "http://localhost:5173/api/workouts"
Response { type: "basic", url: "http://localhost:5173/api/workouts", redirected: false, status: 200, ok: true, statusText: "OK", headers: Headers(6), body: ReadableStream, bodyUsed: false }
​
body: ReadableStream { locked: true }
​​
locked: true
​​
<prototype>: ReadableStreamPrototype { cancel: cancel(), getReader: getReader(), pipeThrough: pipeThrough(), … }
​
bodyUsed: true
​
headers: Headers(6) { "access-control-allow-origin" → "*", "cache-control" → "no-cache", "content-length" → "674", … }
​
ok: true
​
redirected: false
​
status: 200
​
statusText: "OK"
​
type: "basic"
​
url: "http://localhost:5173/api/workouts"
14 replies
KPCKevin Powell - Community
Created by Killer🔪 on 2/7/2024 in #back-end
JSON.parse unexpected error
useEffect on the Home Page
useEffect(() => {
const fetchWorkouts = async () => {
const res = await fetch("/api/workouts")
const json = await res.json()

if (res.ok) {
setWorkouts(json)
}
}
fetchWorkouts()
}, [workouts])
useEffect(() => {
const fetchWorkouts = async () => {
const res = await fetch("/api/workouts")
const json = await res.json()

if (res.ok) {
setWorkouts(json)
}
}
fetchWorkouts()
}, [workouts])
14 replies
KPCKevin Powell - Community
Created by Killer🔪 on 2/7/2024 in #back-end
JSON.parse unexpected error
workoutController
import { Workout } from "../models/workoutSchema.js"
import mongoose from "mongoose"

// * Get all workouts
export const getWorkouts = async (req, res) => {
const workouts = await Workout.find({}).sort({ createdAt: -1 })
res.status(200).json(workouts)
}
import { Workout } from "../models/workoutSchema.js"
import mongoose from "mongoose"

// * Get all workouts
export const getWorkouts = async (req, res) => {
const workouts = await Workout.find({}).sort({ createdAt: -1 })
res.status(200).json(workouts)
}
14 replies
KPCKevin Powell - Community
Created by Killer🔪 on 2/7/2024 in #back-end
JSON.parse unexpected error
workoutSchema for mongodb
import mongoose from "mongoose"

const Schema = mongoose.Schema

const workoutSchema = new Schema(
{
title: {
type: String,
required: true,
},
reps: {
type: Number,
required: true,
},
load: {
type: Number,
required: true,
},
bodyPart: {
type: String,
required: true,
},
},
{ timestamps: true }
)

const Workout = mongoose.model("Workout", workoutSchema)

export { Workout }
import mongoose from "mongoose"

const Schema = mongoose.Schema

const workoutSchema = new Schema(
{
title: {
type: String,
required: true,
},
reps: {
type: Number,
required: true,
},
load: {
type: Number,
required: true,
},
bodyPart: {
type: String,
required: true,
},
},
{ timestamps: true }
)

const Workout = mongoose.model("Workout", workoutSchema)

export { Workout }
14 replies
KPCKevin Powell - Community
Created by Killer🔪 on 1/29/2024 in #back-end
Arrows function can't be hoisted?
Okay, thanks alot @thevanilla13eck. Learnt a new thing today
4 replies
KPCKevin Powell - Community
Created by Killer🔪 on 1/15/2024 in #front-end
Difference between <Doctype> and <!Doctype>
THE kevin replied himself.. Will remember this day forever and thanks a lot for the answer.
3 replies
KPCKevin Powell - Community
Created by Killer🔪 on 11/8/2022 in #front-end
Take full space of the grid col
10 replies
KPCKevin Powell - Community
Created by Killer🔪 on 11/8/2022 in #front-end
Take full space of the grid col
The code is rly bad and I am going to try a diff approach to it but here is the code as it is rn
10 replies
KPCKevin Powell - Community
Created by Killer🔪 on 11/8/2022 in #front-end
Take full space of the grid col
Not that space with the squiggly lines I mean the box having red button and the text I want that to be 100% of the grid box
10 replies
KPCKevin Powell - Community
Created by Killer🔪 on 10/1/2022 in #front-end
0 is causing calculation problem
9 replies
KPCKevin Powell - Community
Created by Killer🔪 on 10/1/2022 in #front-end
0 is causing calculation problem
I did it but its still giving the same error as before
9 replies
KPCKevin Powell - Community
Created by Killer🔪 on 10/1/2022 in #front-end
0 is causing calculation problem
9 replies
KPCKevin Powell - Community
Created by Killer🔪 on 9/26/2022 in #front-end
Cant see the images
but I would really like to figure out why the images arent been accessed from the folder
12 replies
KPCKevin Powell - Community
Created by Killer🔪 on 9/26/2022 in #front-end
Cant see the images
I uploaded the image and used the URL and it worked now somehow
12 replies
KPCKevin Powell - Community
Created by Killer🔪 on 9/26/2022 in #front-end
Cant see the images
Thanks Will try to fix it by changing the folder for the images
12 replies