R
Railway•2y ago
KChammas

fetch data sending %20% instead of space

I have a fetch method and it's sending values correctly to the server, but the server is reading it with the %20% instead of " ". eg.
var query = "hi my name is kevin;I'm 25 yo;I'm a boy"
await fecthPost('/clienteInsert?name=' + query)
var query = "hi my name is kevin;I'm 25 yo;I'm a boy"
await fecthPost('/clienteInsert?name=' + query)
on the server side it receives:
console.log(req.query.name)
> hy%20%my%20%name%20%is%20%kevin;I'm%20%25%20yo;I'm%20%a%20%boy
console.log(req.query.name)
> hy%20%my%20%name%20%is%20%kevin;I'm%20%25%20yo;I'm%20%a%20%boy
I would like to know if there is any how to take off these %20% and others "%"
15 Replies
Percy
Percy•2y ago
Project ID: N/A
KChammas
KChammasOP•2y ago
na
Percy
Percy•2y ago
You might find these helpful: - Server CPU Overload
⚠️ experimental feature
eirk
eirk•2y ago
url encoded is %20
Fragly
Fragly•2y ago
sounds like an easy fix
const text = req.query.name.replace("%20%", " ")
const text = req.query.name.replace("%20%", " ")
KChammas
KChammasOP•2y ago
This is my fetch Post method
const resp = await fetch(url, {
method: 'POST',
headers: {
"Content-Type": "application/json; charset=UTF-8;",
}
});


const data = await resp.json();
return data
const resp = await fetch(url, {
method: 'POST',
headers: {
"Content-Type": "application/json; charset=UTF-8;",
}
});


const data = await resp.json();
return data
But I have more things then just the %20%
Fragly
Fragly•2y ago
oh, fair 🤔
eirk
eirk•2y ago
what else
Fragly
Fragly•2y ago
if your headers are correct it's probably an issue with whatever is sending it that's my guess anyway I'm sure there's a library out there that decodes it for you- or you can make your own I doubt it'll take long
KChammas
KChammasOP•2y ago
This is what I'm trying to send:
"åsdås´d a;54;åsdås´d as d;åsdås´d as d;åsdås´d as d;åsdås´d as d;´2121;åsdås´d as d;000-00;ENEL - SP;18%;18%;18%;18%;33;18%;TRIFÁSICO;62,5;1;verde;"
"åsdås´d a;54;åsdås´d as d;åsdås´d as d;åsdås´d as d;åsdås´d as d;´2121;åsdås´d as d;000-00;ENEL - SP;18%;18%;18%;18%;33;18%;TRIFÁSICO;62,5;1;verde;"
this is what it receives:
%22%C3%A1sd%C3%A1s%C2%B4d%20a;54;%C3%A1sd%C3%A1s%C2%B4d%20as%20d;%C3%A1sd%C3%A1s%C2%B4d%20as%20d;%C3%A1sd%C3%A1s%C2%B4d%20as%20d;%C3%A1sd%C3%A1s%C2%B4d%20as%20d;%C2%B42121;%C3%A1sd%C3%A1s%C2%B4d%20as%20d;000-00;ENEL%20-%20SP;18%;18%;18%;18%;33;18%;TRIF%C3%81SICO;62,5;1;verde;%22
%22%C3%A1sd%C3%A1s%C2%B4d%20a;54;%C3%A1sd%C3%A1s%C2%B4d%20as%20d;%C3%A1sd%C3%A1s%C2%B4d%20as%20d;%C3%A1sd%C3%A1s%C2%B4d%20as%20d;%C3%A1sd%C3%A1s%C2%B4d%20as%20d;%C2%B42121;%C3%A1sd%C3%A1s%C2%B4d%20as%20d;000-00;ENEL%20-%20SP;18%;18%;18%;18%;33;18%;TRIF%C3%81SICO;62,5;1;verde;%22
Fragly
Fragly•2y ago
<:e_guh:1082624029971726356>
KChammas
KChammasOP•2y ago
Hahahah
eirk
eirk•2y ago
then use a url decoding library
KChammas
KChammasOP•2y ago
It's weird because it only gives that error when I send too many data, if it's not too much, it goes just fine I found out what was it, the problem was the "%" I was sending with
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server