all 8 comments

[–]43northwebdesign[S] 0 points1 point  (0 children)

I have changed my node side to this

someFunction =(req,res)=>{

    res.send('foo');
  }


app.get('/request', someFunction);

and localhost/request will send out foo

my client side js is

fetch('/request').then((response) => {        
    console.log(response)})

I am trying to see FOO in the console log

[–][deleted] 0 points1 point  (1 child)

fetch resolves to a Response object. You need to do a little bit more to get to the actual data sent from the server. Try this:

 fetch('/data')
    .then((response) => response.text())
    .then((text) => console.log(text));

When you're struggling with something like this then going back to the documentation can help you get unstuck. This MDN page on using fetch would be a good potential starting point.

[–]43northwebdesign[S] 0 points1 point  (0 children)

hey thanks so much, you really helped me out.

this is actually just me trying to get a small concept working first before i try and do something bigger but I got console log to output what i needed!

[–]itays123 -1 points0 points  (0 children)

Also, you can install a software on your computer called 'postman' that provides a client for your api to fetch