post

차노·2023년 8월 4일
0

JS

목록 보기
31/96

HTTP requests eanble front-end applications to communicate with a back-end server or database.

HTTP request는 프론트앤드와 백엔드 서버(DB)의 연결을 가능하게 한다.

The POST method, which you may use to transmit data to a server, is one of the five primary HTTP ways to send reqeusts and communicate with your servers.

데이터를 서버 측에 전달하는 데 사용되는 포스트 메소드는 request를 보내여 서버 측과 소통할 수 있는 HTTP의 다섯 가지 방법 중 하나이다

  • To submit (send) data to a server to be processed and stored, such as when submitting a form or uploading a file.

    형식을 보내거나 파일을 업로드할 때 서버 측에 데이터를 보내어 실행되고 저장할 수 있게끔 한다.

  • To update data on the server, such as updating the status of a task or modifying an entry in a database.

    일의 상태를 업데이트 하거나 데이터베이스 내의 엔트리를 변경하는 것과 같이 서버의 데이터를 변경할 때 사용한다.

  • To send sensitive information, such as passwords or other confinectial data, as they are less likely to be intercepted than other request.

    다른 요청에 의해 가로채지 않도록 패스워드와 같은 민감한 정보들을 보낼 때 사용한다.

  • To send large amounts of data, because they can handle more significant amoutns of data than otehr requests, making them useful for sending large files or data sets.

    대량의 파일 또는 데이터 군을 활용이 가능하도록 해주기 때문에 (다른 request 보다 상당히 많은 데이터 처리를 가능하기 때문에) 활용한다

  • To support API interactions, because many APIs use such request to create, update, or retireve data from a server.

    많은 API가 서버로부터 데이터를 만들고, 변경하고, 되찾도록 하는 request를 사용하기 때문에, API 인터랙션을 지원한다.

  • To send multiple parameters, becasue these requests can send mulitple parameters in the body, allowing more complex data to be sent to the server.

    이러한 request는 바디 내에서 다중의 매개변수들을 보내어 서버 측에 복잡한 데이터가 보낼 수 있도록 해주기 때문에 다량의 파라미터를 보낸다.

How to Send a POST Request with Fetch API

The FetchAPI is a built-in method that requires only one parameter: the endpoint (API URL)

패치 API는 하나의 파라미터만 필요로 하는 내장형 메소드이다.

While the additional arguments are not required for a GET request, tehy are highyl beneficial for a POST HTTP request.

더 많은 인자를 필요로 하지 않는 GET request와 다르게, POST reqeust는 상당히 효율적이다.

The second parameter provides the body (data to be sent) and the kind of request to be made, while the third parameter is a header that identifies the type of data to be trasmitted, such as JSON.

두 번째 매개변수는 보내야 할 데이터(body)와 일종의 요청들을 해주며, 세 번째 파라미터는 JSON과 같이 전송되어야 하는 데이터의 유형을 확인하는 헤더이다.

The JSON stringify is used to convert this object into JSON string, which can then be passed as the body of the request.

JSON stringify는 객체를 제이슨 스트링으로 변환하는 데 사용되고 나서 요청의 바디로서 보내진다.

This code sends an HTTP POST request to the endpoint using Fetch ().

이 코드는 fetch()를 이용해서 엔드포인트로 HTTP POST 요청을 보내고 있다.

The body property of the object passed to Fetch () is set to formData, which contains the file we want to send.

페치로 전달된 객체의 바디 프로퍼티는 보내고자 하는 파일을 포함한 formData로 설정되어 있다.

Reference

0개의 댓글