-
Notifications
You must be signed in to change notification settings - Fork 0
/
met.js
33 lines (28 loc) · 829 Bytes
/
met.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//JONATHAN MELESIO CARDENAS GARCIA A00818821
//2° PARCIAL DE DESAROLLO WEB
const request = require('request')
const searchObject = function(qObject, callback){
const url = 'https://collectionapi.metmuseum.org/public/collection/v1/search?q='+qObject;
request({ url, json: true }, function(error, response) {
if (error) {
console.log("ERROR");
console.log(error);
callback('Service unavailable', undefined);
} else {
const data = response.body
if(data.total == 0){
callback('No hay resultados para esta busqueda',undefined);
} else{
console.log("SUCCESS");
const info = {
objectID: data.objectIDs[0]
}
console.log(info);
callback(undefined, info);
}
}
})
}
module.exports = {
searchObject: searchObject
}