Need help running the Microservice Timestamp

Hi everyone, please i need some help running my code in replit. I made the coding of the project on the server.js file and when I copy the link to run the project and I paste it in another browser it runs without problem but when I put the link in the part "solution link "all other instructions are false apart from the first instruction.
Here is my code:

// server.js
// where your node app starts

// init project
var express = require('express');
var app = express();

// enable CORS (
// so that your API is remotely testable by FCC 
var cors = require('cors');
app.use(cors({ optionsSuccessStatus: 200 }));  // some legacy browsers choke on 204


app.get("/", function(req, res) {
  res.sendFile(__dirname + '/views/index.html');

// your first API endpoint... 
app.get("/api/timestamp/:timestamp", function(req, res) {
  let timestamp = req.params.timestamp;
    timestamp = +timestamp;
  let date = new Date(timestamp);
  if(date.toUTCString() == "Invalid Date"){
    res.json({error: date.toUTCString()})
  res.json({ unix: date.valueOf(), utc: date.toUTCString() });

app.get("/api/timestamp/", (req, res) => {
  let date = new Date();
  res.json({ unix: date.valueOf(), utc: date.toUTCString() });

// listen for requests :)
var listener = app.listen(process.env.PORT, function() {
  console.log('Your app is listening on port ' + listener.address().port);

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.