第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

NODE JS + Postman:無法修補(bǔ) URL

NODE JS + Postman:無法修補(bǔ) URL

慕慕森 2021-09-30 17:33:42
考慮代碼:const fs = require('fs');const express = require('express');const app = express();const bodyParser = require('body-parser')// use middlewareapp.use(express.json());app.use(bodyParser.json());const fileLocation = `${__dirname}/dev-data/data/tours-simple.json`;const theTours = JSON.parse(fs.readFileSync(fileLocation));app.patch('api/v1/tours/:id', (req, res) =>{  if (req.params.id * 1 > theTours.length) {    return res.status(404).json({      status: 'fail',      message: 'Invalid ID'    });  }  res.status(200).json({    status: 'success',    data: {      tour: '<Updated tour here ...>'    }  });});const port = 3000;app.listen(port, () => {  console.log(`App is running on port ${port}`);});當(dāng)我嘗試從 Postman 修補(bǔ) URL 時(shí):Action PATCH URL : 127.0.0.1:3000/api/v1/tours/3發(fā)送原始:我明白了:為什么會(huì)這樣?我哪里做錯(cuò)了 ?
查看完整描述

2 回答

?
月關(guān)寶盒

TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超5個(gè)贊

您在路線中缺少斜線:

app.patch('/api/v1/tours/:id', (req, res) =>{


查看完整回答
反對(duì) 回復(fù) 2021-09-30
?
函數(shù)式編程

TA貢獻(xiàn)1807條經(jīng)驗(yàn) 獲得超9個(gè)贊

定義路線時(shí),您缺少前導(dǎo) /(斜線)


app.patch('/...', (req, res) => { 

    ... 

    ...

 });

Express 需要在定義路由時(shí)使用前導(dǎo)斜杠 :) 希望這會(huì)有所幫助


查看完整回答
反對(duì) 回復(fù) 2021-09-30
  • 2 回答
  • 0 關(guān)注
  • 213 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)