카테고리 없음

[기타] post 가 안 된다?

나스닥171819 2020. 5. 20. 10:38
728x90
반응형

https://m.blog.naver.com/PostView.nhn?blogId=wideeyed&logNo=221350638501&proxyReferer=https:%2F%2Fwww.google.com%2F

 

cURL 소개, HTTP GET, POST 호출 방법

cURL이란? 다양한 프로토콜을 지원하는 데이터 전송용 Command Line Tool이다. (HTTP, HTTP...

blog.naver.com

맥을 많이 쓰는 이유가 있다.

 

윈도우 시스템에서 post 를 사용하기 위해서는 약간의 수정이 필요하다.

 

본체 예제

 

https://github.com/mjhea0/express-crud-pg-promise

 

mjhea0/express-crud-pg-promise

Just a basic Node + Express CRUD app with pg-promise - mjhea0/express-crud-pg-promise

github.com

 

// add a beer

router.post('/:id/secret/', (reqresnext=> {

  const newBeer = {

    name: req.body.name,

    abv: parseInt(req.body.abv),

    brand: req.body.brand,

    style: req.body.style

  };

  queries.add('beer'newBeer)

  .then((beers=> {

    res.send('You added a beer!');

  })

  .catch((error=> {

    next(error);

  });

});

 

 

 

 

curl -d "{""name"":""concentration"", ""abv"":""9"" , ""brand"":""russian river"", ""style"":""sour porter""}" -H "Content-Type: application/json" -X POST http://localhost:3000/api/v1/beers/3/secret

 

 

반응형