Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- ExceptionResolver
- wrapper class
- Transaction
- 단어변환
- NestJS 요청흐름
- CQS
- 프로그래머스
- HandlerMethod
- assertJ
- #@Transacional
- propagation
- 벌크연산
- hoisting
- Java
- CORS
- TDZ
- RequestMappingHandlerMapping
- 역정규화
- cross-cutting concerns
- generic type
- IllegalStateException
- COPYOFRANGE
- demand paging
- type eraser
- SPOF
- optimistic lock
- pessimistic lock
- API
- Generic method
- tracking-modes
Archives
- Today
- Total
jingyulog
API remind 본문
같은 예금 창구에서도 개인 고객이냐 기업 고객이냐에 따라 달리 처리하는 것처럼, 클라이언트가 요청할 때도 방식이 존재한다.
즉, HTTP 라는 통신 규약을 따르는데, 클라이언트는 요청할 때 HTTP request method를 통해서 어떤 요청 종류인지 응답하는 서버 쪽에 정보를 알려준다.
HTTP request method
GET, POST, PATCH, PUT, DELETE 등 여러 방식이 존재하고, 그 중 가장 많이 쓰이는 GET, POST 방식에 대해 리마인드해본다..
- GET
- 통상적으로 데이터 조회를 요청할 때 사용
- 데이터를 전달하기 위해서 URL 뒤에 물음표를 붙여 key=value 형태로 전달한다.
- POST
- 통상적으로 데이터 생성, 변경, 삭제시에 사용한다.
- 예) 회원가입, 회원탈퇴, 비밀번호 수정
- 데이터를 전달하기 위해서 바로 HTML body에 key:value 형태로 전달한다.
GET, POST 요청에서 클라이언트의 데이터를 받는 방법
- backend
@app.route('/test', methods=['GET'])
def test_get():
title_receive = request.args.get('title_give')
print('get 요청에 대한 응답:', title_receive)
return jsonify({'result': 'success', 'msg': '이 요청은 GET 요청입니다.'})
@app.route('/test', methods=['POST'])
def test_post():
title_receive = request.form['title_give']
print('post 요청에 대한 응답:', title_receive)
return jsonify({'result': 'success', 'msg': '이 요청은 POST 요청입니다.'})
- frontend
<script type="text/javascript">
function get_test(){
$.ajax({
type: "GET",
url: "/test?title_give=봄날은간다",
data: {},
success: function(response){
console.log(response)
}
})
}
function post_test() {
$.ajax({
type: "POST",
url: "/test",
data: { title_give: '어벤져스' },
success: function(response) {
console.log(response)
}
})
}
</script>
'컴퓨터 사이언스 > 개발 상식' 카테고리의 다른 글
반복문, 재귀함수 (0) | 2023.10.16 |
---|---|
html - div, article, section 의 차이 (0) | 2023.08.12 |
크롬 개발자도구 이용한 디버깅 (0) | 2023.05.07 |
API에 관하여 (0) | 2023.05.06 |
Git 기초 사용법 (0) | 2023.05.05 |