[ad_1]
I have this if
statement that chooses between two completely different JSON object (displayed below).
I need to display the result on the client side of things, I’m stomped tbh
My goal: I need to be able to display either the error
part of the object, or the count
part on the page. I’m sure there’s something I’m missing,
My constraints is that I can’t change anything within the JSON files.
Node.js and express related, my background is in basic Java though ;-;
Part of the code I have:
Server side
server.post(etc)
.
.
.
if(!textInputted.text){
result = ({
error: "Parameter text is missing."
})} else{
result = ({
count: numOfWords
})
}
console.log(result)
res.json(result)
Client side
(it’s just this at the moment, I kept adding and removing)
fetch(etc)
.
.
.
.then (function(res){
return res.json()
[ad_2]