I've tried make a service using javascript (specifically fetch metode) but appear this error: Failed to load resource: the server responded with a status of 401 (Unauthorized). The credentials are fine because I've test this in postman.
Url where I have the service: https://felipemoreno.co/server.html
I'm using this code:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
console.log("prueba 352");
var markers = {}; //create obj
var markersss_array = []
markersss_array.push("1019035955");
//more datas push in array
markers["identificacion"] = markersss_array; //pass aray to json object
var markersConvertido = JSON.stringify(markers);
var url = 'https://osb.urosario.edu.co/uxxi-URO/WsFotografias/proxy/AdministradorFotografiasJsonPS/fotos/consultar';
var username = 'USERNAME';
var password = 'PASSWORD';
let headers = new Headers();
//headers.append('Content-Type', 'text/json');
headers.set('Authorization', 'Basic ' + btoa(username + ":" + password));
headers.set('Content-type', 'application/json; charset=utf-8');
fetch(url, {method:'POST',
mode: 'no-cors',
headers: headers,
body: markersConvertido
})
.then(response => {
if (!response.ok) throw new Error(response.status);
return response.json();
});
</script>
</body>
</html>