Skip to content

Commit b473409

Browse files
committed
1.0.1 version OK depues de refactorizacion
1 parent 9fad2a4 commit b473409

File tree

7 files changed

+60
-10
lines changed

7 files changed

+60
-10
lines changed

.npmignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules/
2+
package-lock.json
3+
lib/
4+
test/
5+
pruebas.js
6+
.gitignore

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Vamos a obtener la respuesta del tiempo actual de un lugar seleccionado usando d
44
## Instalación
55
Tenemos que seguir estas instrucciones de instalación
66
```
7-
npm install <package>
7+
npm install anartz-proyecto-2-openweather-api
88
```
99
## Uso
1010

dist/services/api.service.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ export declare class ApiService {
3131
* @param codPais Código del pais del lugar
3232
*/
3333
buscarPorZipCodigoPostal(cp: string, codPais?: string): Promise<any>;
34+
private requestApi;
3435
}

dist/services/api.service.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ class ApiService {
5151
}
5252
// LLamada a la api
5353
const url = `${constants_1.URL_LOCALHOST}${constants_1.CURRENT}${filtro}${parametros}`;
54-
return axios_1.default.get(url).then(e => { return e.data; }).catch(error => { return error; });
54+
/*return axios.get(url).then(
55+
e => { return e.data }
56+
).catch(
57+
error => {return error}
58+
);*/
59+
return this.requestApi(url);
5560
}
5661
/**
5762
* Obtener el tiempo mediante la localizacion
@@ -69,7 +74,12 @@ class ApiService {
6974
}
7075
// LLamada a la api
7176
const url = `${constants_1.URL_LOCALHOST}${constants_1.CURRENT}${filtro}${parametros}`;
72-
return axios_1.default.get(url).then(e => { return e.data; }).catch(error => { return error; });
77+
/*return axios.get(url).then(
78+
e => { return e.data }
79+
).catch(
80+
error => {return error}
81+
);*/
82+
return this.requestApi(url);
7383
}
7484
/**
7585
* Obtenemos mediante el codigo postal del lugar
@@ -87,6 +97,16 @@ class ApiService {
8797
}
8898
// LLamada a la api
8999
const url = `${constants_1.URL_LOCALHOST}${constants_1.CURRENT}${filtro}${parametros}`;
100+
/*return axios.get(url).then(
101+
e => { return e.data }
102+
).catch(
103+
error => {return error}
104+
);*/
105+
return this.requestApi(url);
106+
}
107+
requestApi(url) {
108+
// LLamada a la api
109+
// const url = `${URL_LOCALHOST}${CURRENT}${filtro}${parametros}`;
90110
return axios_1.default.get(url).then(e => { return e.data; }).catch(error => { return error; });
91111
}
92112
}

lib/services/api.service.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ export class ApiService {
5151
// LLamada a la api
5252
const url = `${URL_LOCALHOST}${CURRENT}${filtro}${parametros}`;
5353

54-
return axios.get(url).then(
54+
/*return axios.get(url).then(
5555
e => { return e.data }
5656
).catch(
5757
error => {return error}
58-
);
58+
);*/
59+
return this.requestApi(url);
5960
}
6061

6162
/**
@@ -75,11 +76,12 @@ export class ApiService {
7576
// LLamada a la api
7677
const url = `${URL_LOCALHOST}${CURRENT}${filtro}${parametros}`;
7778

78-
return axios.get(url).then(
79+
/*return axios.get(url).then(
7980
e => { return e.data }
8081
).catch(
8182
error => {return error}
82-
);
83+
);*/
84+
return this.requestApi(url);
8385
}
8486

8587
/**
@@ -99,6 +101,18 @@ export class ApiService {
99101
// LLamada a la api
100102
const url = `${URL_LOCALHOST}${CURRENT}${filtro}${parametros}`;
101103

104+
/*return axios.get(url).then(
105+
e => { return e.data }
106+
).catch(
107+
error => {return error}
108+
);*/
109+
return this.requestApi(url);
110+
}
111+
112+
private requestApi(url :string) {
113+
// LLamada a la api
114+
// const url = `${URL_LOCALHOST}${CURRENT}${filtro}${parametros}`;
115+
102116
return axios.get(url).then(
103117
e => { return e.data }
104118
).catch(

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
2-
"name": "proyecto-2-openweather-api",
2+
"name": "anartz-proyecto-2-openweather-api",
33
"version": "1.0.0",
44
"description": "Acceso a la API de Openweather",
5-
"main": "index.js",
5+
"main": "./dist/index.js",
6+
"types": "./dist/index.d.ts",
67
"scripts": {
78
"test": "mocha",
89
"watch": "tsc -w"

pruebas.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
const m = require('./dist').ApiService;
22

33

4-
const api = new m('<APIKEY>', 'es', 'm');
4+
const api = new m('ec32f42ea9357dae4e8e8dbc6d0f77f9', 'es', 'm');
55

66
api.buscarPorNombre('Barcelona', 'es').then(
77
data => console.log(data)
8+
);
9+
10+
api.buscarPorLocalizacionGeografica({ lat: -33.8473567, lon: 150.6517943 }).then(
11+
data => console.log(data)
12+
);
13+
14+
api.buscarPorZipCodigoPostal('21260' , 'mx').then(
15+
data => console.log(data)
816
);

0 commit comments

Comments
 (0)