This commit is contained in:
Francesco Esposito 2019-08-22 17:27:23 +02:00
parent 0518b6b331
commit 9b2af6eb53
1 changed files with 39 additions and 0 deletions

39
src/api.js Normal file
View File

@ -0,0 +1,39 @@
import axios from 'axios';
import config from './config';
import logger from './logger';
export const rainCheck = (cityId) => {
const options = {
params: {
cityId,
},
};
return axios.get(`${config.umbrello.apiURL}/weather/forecast`, options)
.then((res) => {
const { data } = res;
// const flag = (data.rain === 'Y');
return Promise.resolve(data);
})
.catch((err) => {
logger.error(err);
Promise.reject(err);
});
};
export const searchCity = (cityName) => {
const options = {
params: {
city: cityName,
},
};
return axios.get(`${config.umbrello.apiURL}/weather/search`, options)
.then((res) => Promise.resolve(res.data))
.catch((err) => {
logger.error(err);
Promise.reject(err);
});
};