CheckDB.js 1.68 KB
Newer Older
1
import axios from 'axios';
Spark's avatar
Spark committed
2
import { Swal } from 'sweetalert2';
Spark's avatar
Spark committed
3
import { routesClient } from './../routesClient';
Spark's avatar
Spark committed
4

Spark's avatar
Spark committed
5
6
7
8
9
10
11

export async function callUserInfo() {
    const res = await axios.get(routesClient.userinfo)
    return res.data.contents.user_info
}

export function getWeatherOut() {
Spark's avatar
Spark committed
12
    callUserInfo().then((res) => {
Spark's avatar
Spark committed
13
14
15
16
        console.log(res)
        // if (res['loc_code'] === null) {
            res['loc_code'] = 3743011
        // }
Spark's avatar
Spark committed
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
        const outs = axios.get(routesClient.outsideLoc + res['loc_code'])
        return outs
            .then((res) => {
                const outWeather = res.data.contents.weather_out
                console.log(res.data.contents.weather_out)
                let i = 0;
                // setTemp(res.data.contents.weather_out[0].temp)
                const tempArray = []
                for (i; i < 3; i++) {
                    console.log(i)
                    console.log(outWeather[i])
                    tempArray.push(outWeather[i].temp)
                }
                return tempArray
                // setTemp(tempArray)
            })
    })
}
35

Spark's avatar
Spark committed
36
37
38
39
40
export function checkCookies() {
    const acctoken_cookies = document.cookie.split('=')[1];
    return acctoken_cookies;
}

41
export function deleteCookie(name) {
Spark's avatar
Spark committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
    document.cookie = name + '=; expires=Thu, 01 Jan 1999 00:00:10 GMT;';
    Swal.fire({
        title: '로그아웃 성공!',
        text: '🙏 안녕히 가세요 🙏',
        icon: 'warning',
        customClass: 'swal-wide',
        confirmButtonText: '확인',
    }).then((res) => {
        if (res.isConfirmed) {
            window.location.replace('/')
        }
        else {
            window.location.replace('/')
        }
    })
}