Created
October 8, 2020 10:47
-
-
Save RyanKor/b364d41994b1643f6f5eef4e4cbefef2 to your computer and use it in GitHub Desktop.
axios를 활용해서 request 모듈을 사용해 설명되어 있던 공식 문서 코드를 변형하는 방법을 취해본다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var form = new FormData(); | |
form.append("image", fs.createReadStream(path.join(__dirname + "/sean.jpg"))); | |
axios | |
.post(api_url, form, { | |
headers: { | |
// axios에서는 content-type을 자동으로 바꿔주지 않기 때문에 | |
// 다음과 같이 header를 넣어주어야 합니다 | |
...form.getHeaders(), | |
"X-Naver-Client-Id": process.env.NAVER_CLIENT_ID, | |
"X-Naver-Client-Secret": process.env.NAVER_SECRET_KEY, | |
}, | |
}) | |
.then((response) => { | |
console.log(response.data); | |
res.render("main", response); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment