javascript Express_Discovery.js

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Express_Discovery.js相关的知识,希望对你有一定的参考价值。

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

app.get('/', (request, response) => {
  response.send('Bienvenue sur Express');
});
app.get('/api/movies', (request, response) => {
  response.send('Récupération de tous les films');
});
app.get('/api/movies/:id', (request, response) => {
const id = request.params.id;
  response.json({ id: 1 , 'name' : 'Star Wars'});
});

app.get('/api/employee', (request, response) => {
    const name = request.query.name;
    if(name){
        response.status(404).send(`Cannot find ${name}`);
    }else{
        response.sendStatus(304); 
    }
   
});

app.listen(port, (err) => {
  if (err) {
    throw new Error('Something bad happened...');
  }

  console.log(`Server is listening on ${port}`);
});

以上是关于javascript Express_Discovery.js的主要内容,如果未能解决你的问题,请参考以下文章

javascript JavaScript isset()等效: - JavaScript

JavaScript 使用JavaScript更改CSS(JavaScript)

JavaScript之基础-1 JavaScript(概述基础语法)

前端基础-JavaScript的基本概述和语法

JavaScript

JavaScript