FetchDataDAL.js

23 lines | 539 B Blame History Raw Download
import authService from '../../components/api-authorization/AuthorizeService'

export class FetchDataDAL {

    async GetWeatherData() {
        const token = await authService.getAccessToken();
        const response = await fetch(
            'weatherforecast',
            {
                headers: !token
                    ? {}
                    : {
                        'Authorization': `Bearer ${token}`
                    }
            }
        );
        const data = await response.json();

        return data
    }

}