[FastAPI] FastAPI에서 다른 API 호출하기

_____·2022년 6월 24일
0

FastAPI

목록 보기
3/10

FastAPI로 개발을 해도, 외부의 다른 API를 요청 할 때가 많다. 그럴 땐 httpx를 이용해 아래와 같이 구현 하면 된다.

import httpx

async def call_other_api(...):
    async with httpx.AsyncClient() as client:
        ....
        # response = client.get(...)
        # response = client.post(...)
    	return repsonse
	return response
profile
개발자입니다.

0개의 댓글