node https module

Youngjin Son·2023년 1월 18일
0

APIs

목록 보기
2/4

app.js 파일 작성

const express = require('express');

const app = express();

const port = 3000;

const https = require('node:https');


app.get("/", (req, res) => {
    const url = 'https://api.openweathermap.org/data/2.5/weather?q=Seoul&units=metric&appid={my api key}';
    https.get(url, (response) => {
        console.log(response);
    });
    res.send('Server is up and running.');
});


app.listen(port, () => {
    console.log("Server is running on port " + port);
});

터미널에서 다음 명령어 실행

supervisor app.js

localhost:3000 접속


참고로 https node doc


참고자료
Udemy - The Complete 2023 Web Development Bootcamp (Dr.Angela Yu)

profile
아자아자

0개의 댓글