Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
I cannot get my JavaScript REST API to return data

I know there are many similar questions about this issue and most of them are already answered, but I am a beginner on this.

This code is a code from a YouTube tutorial about the basic of making REST API, as follows:

const app = require('express')();
const PORT = 8095;

app.get('/tshirt', (req, res) => {
    res.status(200).send({
        tshirt: "red white tshirt",
        size: "large"
    })
});

I tried to access get tshirt both from browser and Insomnia and it says 'could not get /tshirt', what might be wrong?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You also need to start the actual server.

const express = require('express');
const app = express();
const port = 8095;

app.get('/tshirt', (req, res) => {
   res.status(200).send({
        tshirt: "red white tshirt",
        size: "large"
    })
});

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)
})

As per https://expressjs.com/en/starter/hello-world.html

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!