I have tried to create a client side function that sends a fetch request for json data and then appends the response to a div however it doesnt seem to be working.
here is the client side function code
function bobFun(){
let response = fetch('http://127.0.0.1:3000/dylan/list', { mode: 'no-cors' })
.then(console.log("fetch sent"))
//.then(console.log(response))
.then(response => {
return response.text().then(text => {
document.getElementById("test").append(text)
});
});
here is the server side json data
let dylan = ['song recommendation 1',
'song recommendation 2',
'song recommendation 3',
];
app.get('/dylan/list', function(req, resp){
resp.send(dylan);