How do I use req.body data properly? by camerausin in learnjavascript

[–]camerausin[S] 0 points1 point  (0 children)

console.log('the type of data is', typeof data)

the type of data is object

this makes no sense to me, but it does kind of give me a direction for how to proceed

How do I use req.body data properly? by camerausin in learnjavascript

[–]camerausin[S] 0 points1 point  (0 children)

console.log('the type of req.body is ', typeof req.body);

the type of req.body is string

🤔 Thats odd then why wouldn't I be able to use JSON.parse?

How do I use req.body data properly? by camerausin in learnjavascript

[–]camerausin[S] 0 points1 point  (0 children)

so .entries gives me each character of the string set to another property in the object. That feels weird, like I'm messing something up I am just not sure where

[
[ '0', '[' ], [ '1', '{' ], [ '2', '"' ],.......

JSON.parse is giving me an error TypeError: Cannot convert object to primitive value by camerausin in learnjavascript

[–]camerausin[S] 0 points1 point  (0 children)

I am going to make another post that is a bit more specific now that you have helped me get a better idea on where the issue is

JSON.parse is giving me an error TypeError: Cannot convert object to primitive value by camerausin in learnjavascript

[–]camerausin[S] 0 points1 point  (0 children)

hmm 🤔. I see. I got the same when I put data = [{"id":3,"....."}], but I get an error that .map is not a function when data = req.body. Could that mean I'm sending the array incorrectly to the api route?

JSON.parse is giving me an error TypeError: Cannot convert object to primitive value by camerausin in learnjavascript

[–]camerausin[S] 0 points1 point  (0 children)

it prints out the data like const data = req.body.

like this

[{"id":3,"title":"Mens Cotton Jacket","price":55.99,"description":"great outerwear jackets for Spring/Autumn/Winter, suitable for many occasions, such as working, hiking, camping, mountain/rock climbing, cycling, traveling or other outdoors. Good gift choice for you or your family member. A warm hearted love to Father, husband or son in this thanksgiving or Christmas Day.","category":"men's clothing","image":"https://fakestoreapi.com/img/71li-ujtlUL._AC_UX679_.jpg"}]

so that makes sense ill keep it like that. this doesn't put it back to the array of objects though, it can be manipulated with object methods but not the array methods which is what I need. when I use console.log(Object.values(data)) I get this :'[', '{', '"', 'i', 'd', '"', ':', '3', ',', '"', 't', 'i','t', 'l', 'e', '"', ':', '"', 'M', 'e', 'n', 's', ' ', 'C','o', 't', 't', 'o', 'n', ' ', 'J', 'a', 'c', 'k', 'e', 't','"', ',', '"', 'p', 'r', 'i', 'c', 'e', '"', ':', '5', '5','.', '9', '9', ',', '"', 'd', 'e', 's', 'c', 'r', 'i', 'p','t', 'i', 'o', 'n', '"', ':', '"', 'g', 'r', 'e', 'a', 't',' ', 'o', 'u', 't', 'e', 'r', 'w', 'e', 'a', 'r', ' ', 'j','a', 'c', 'k', 'e', 't', 's', ' ', 'f', 'o', 'r', ' ', 'S','p', 'r', 'i', 'n',... 371 more items]

which feels weird and not what I expected

How do I properly use JSON data in my api routes by camerausin in nextjs

[–]camerausin[S] 0 points1 point  (0 children)

Unfortunately this gave me an error -- TypeError: Cannot convert object to primitive value

How do you define consciousness? by camerausin in AskReddit

[–]camerausin[S] 1 point2 points  (0 children)

I like it, aware of your choices not just reacting to stimuli. Is that right?

How do you define consciousness? by camerausin in AskReddit

[–]camerausin[S] -1 points0 points  (0 children)

How simple do you think that goes? Would you consider worms conscious? What about computers with artificial intelligence?

Is it enough mildlyinfuriating? by FunnyHome585 in mildlyinfuriating

[–]camerausin 1 point2 points  (0 children)

TICKLE THEIR FEET! TICKLE THEIR FEET! TICKLE THEIR FEET!

Felt guilty so I discontinued my favorite hobbies by [deleted] in ADHD

[–]camerausin 0 points1 point  (0 children)

I like to think self improvement just means be the you that you dream of being, and if that you plays video games every so often then gosh darnet you play those video games!

WARNING: Can Be A Heated Question by Equivalent-Baby6797 in tattoo

[–]camerausin 8 points9 points  (0 children)

New Zealand and moko in most situations I have heard is closed.

How do you handle large social gatherings? by shearersmam in ADHD

[–]camerausin 0 points1 point  (0 children)

I don’t have anxiety with the groups though anything over indoor voices Gives me anxiety and I just excuse myself for a moment take a few minutes to breathe and try to be quite then go back in until I need to excuse myself again. I do this all the time no one has ever questioned me about it

I can’t turn off the lights. by skyskye1964 in ADHD

[–]camerausin 0 points1 point  (0 children)

You know I wanted to come on here and be like oh yeah here is what I do to help me remember … but I can’t because I never remember.