Skip to content

Commit

Permalink
Update server.ts
Browse files Browse the repository at this point in the history
Allowing users send raw data (json)
  • Loading branch information
AnitaMatt authored Aug 16, 2022
1 parent 24fe8c4 commit 1d3312d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion course-02/exercises/udacity-c2-basic-server/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import express, { Router, Request, Response } from 'express';
import bodyParser from 'body-parser';
// import bodyParser from 'body-parser'; deprecated
const bodyParser = require('body-parser')

import { Car, cars as cars_list } from './cars';

Expand All @@ -14,6 +15,7 @@ import { Car, cars as cars_list } from './cars';
//use middleware so post bodies
//are accessable as req.body.{{variable}}
app.use(bodyParser.json());
app.use(express.urlencoded({ extended: true })) //for requests from forms-like data

// Root URI call
app.get( "/", ( req: Request, res: Response ) => {
Expand Down

0 comments on commit 1d3312d

Please sign in to comment.