I'm trying to make a few query's on a Real Estate Website.
When i make the fetch request with words like 'Næstved','Præstø',Karrebæksminde
, i get a bad response because æ,ø
etc gets replaced by ?
symbol ??? I tried to escape the response and it seems to work at times ... but i mostly get empty responses....
You can try yourself to make a query here: https://home.dk/umbraco/backoffice/home-api/BoligOrAddress/Boligdata?max=100&searchstring=N%C3%A6stved
Here is the code:
var cities = [
'København',
'København K',
'Næstved'
];
var promises = cities.map(city =>
fetch(`https://home.dk/umbraco/backoffice/home-api/BoligOrAddress/Boligdata?max=1000000000&searchstring=${city}`)
.then(response => response.json())
.then(validate => { if(validate.Successed && validate.Status === 'OK') return validate })
.then(pushAlll => { pushedSuggestions.push(pushAlll); return pushAlll })
Promise.all(promises).then(results => {
console.log(results);
});
The problem is i get results like this { suggest: 'N�stved', count: ''}
When i should be getting this:
[
{
suggest: "Næstved kommune",
count: "854"
},
{
suggest: "Næstved, 4700",
count: "406"
},
[
{
suggest: "Næstved Landevej, 4243 Rude",
count: "1"
},
{
suggest: "Næstved Landevej, 4250 Fuglebjerg",
count: "1"
},
{
suggest: "Næstvedvej, 4100 Ringsted",
count: "2"
},
{
suggest: "Næstvedvej, 4230 Skælskør",
count: "3"
},
{
suggest: "Næstvedvej, 4684 Holmegaard",
count: "2"
},
{
suggest: "Næstvedvej, 4720 Præstø",
count: "4"
},
{
suggest: "Næstvedvej, 4750 Lundby",
count: "1"
},
{
suggest: "Næstvedvej, 4760 Vordingborg",
count: "4"
}
]
via Octavian L
No comments:
Post a Comment