File tree Expand file tree Collapse file tree 7 files changed +60
-10
lines changed Expand file tree Collapse file tree 7 files changed +60
-10
lines changed Original file line number Diff line number Diff line change
1
+ node_modules /
2
+ package-lock.json
3
+ lib /
4
+ test /
5
+ pruebas.js
6
+ .gitignore
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ Vamos a obtener la respuesta del tiempo actual de un lugar seleccionado usando d
4
4
## Instalación
5
5
Tenemos que seguir estas instrucciones de instalación
6
6
```
7
- npm install <package>
7
+ npm install anartz-proyecto-2-openweather-api
8
8
```
9
9
## Uso
10
10
Original file line number Diff line number Diff line change @@ -31,4 +31,5 @@ export declare class ApiService {
31
31
* @param codPais Código del pais del lugar
32
32
*/
33
33
buscarPorZipCodigoPostal ( cp : string , codPais ?: string ) : Promise < any > ;
34
+ private requestApi ;
34
35
}
Original file line number Diff line number Diff line change @@ -51,7 +51,12 @@ class ApiService {
51
51
}
52
52
// LLamada a la api
53
53
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 ) ;
55
60
}
56
61
/**
57
62
* Obtener el tiempo mediante la localizacion
@@ -69,7 +74,12 @@ class ApiService {
69
74
}
70
75
// LLamada a la api
71
76
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 ) ;
73
83
}
74
84
/**
75
85
* Obtenemos mediante el codigo postal del lugar
@@ -87,6 +97,16 @@ class ApiService {
87
97
}
88
98
// LLamada a la api
89
99
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}`;
90
110
return axios_1 . default . get ( url ) . then ( e => { return e . data ; } ) . catch ( error => { return error ; } ) ;
91
111
}
92
112
}
Original file line number Diff line number Diff line change @@ -51,11 +51,12 @@ export class ApiService {
51
51
// LLamada a la api
52
52
const url = `${ URL_LOCALHOST } ${ CURRENT } ${ filtro } ${ parametros } ` ;
53
53
54
- return axios . get ( url ) . then (
54
+ /* return axios.get(url).then(
55
55
e => { return e.data }
56
56
).catch(
57
57
error => {return error}
58
- ) ;
58
+ );*/
59
+ return this . requestApi ( url ) ;
59
60
}
60
61
61
62
/**
@@ -75,11 +76,12 @@ export class ApiService {
75
76
// LLamada a la api
76
77
const url = `${ URL_LOCALHOST } ${ CURRENT } ${ filtro } ${ parametros } ` ;
77
78
78
- return axios . get ( url ) . then (
79
+ /* return axios.get(url).then(
79
80
e => { return e.data }
80
81
).catch(
81
82
error => {return error}
82
- ) ;
83
+ );*/
84
+ return this . requestApi ( url ) ;
83
85
}
84
86
85
87
/**
@@ -99,6 +101,18 @@ export class ApiService {
99
101
// LLamada a la api
100
102
const url = `${ URL_LOCALHOST } ${ CURRENT } ${ filtro } ${ parametros } ` ;
101
103
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
+
102
116
return axios . get ( url ) . then (
103
117
e => { return e . data }
104
118
) . catch (
Original file line number Diff line number Diff line change 1
1
{
2
- "name" : " proyecto-2-openweather-api" ,
2
+ "name" : " anartz- proyecto-2-openweather-api" ,
3
3
"version" : " 1.0.0" ,
4
4
"description" : " Acceso a la API de Openweather" ,
5
- "main" : " index.js" ,
5
+ "main" : " ./dist/index.js" ,
6
+ "types" : " ./dist/index.d.ts" ,
6
7
"scripts" : {
7
8
"test" : " mocha" ,
8
9
"watch" : " tsc -w"
Original file line number Diff line number Diff line change 1
1
const m = require ( './dist' ) . ApiService ;
2
2
3
3
4
- const api = new m ( '<APIKEY> ' , 'es' , 'm' ) ;
4
+ const api = new m ( 'ec32f42ea9357dae4e8e8dbc6d0f77f9 ' , 'es' , 'm' ) ;
5
5
6
6
api . buscarPorNombre ( 'Barcelona' , 'es' ) . then (
7
7
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 )
8
16
) ;
You can’t perform that action at this time.
0 commit comments