-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforInstagram.js
65 lines (63 loc) · 1.49 KB
/
forInstagram.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
var express = require('express')
var router = express.Router()
const getIt = require("./mainFunct")
const fetch = require('node-fetch')
router.get("/", (req,res)=>{
fetch('https://disease.sh/v2/all')
.catch(err =>{
res.send("Error Occured")
console.log(err)
})
.then(response =>{
if (response.ok) {
return response.json()
} else {
res.sendStatus(404)
res.json("error: Something is wrong.")
return;
}
})
.then(data => {
res.setHeader("Content-Type", "image/jpeg");
getIt(data, "false", "","ig")
.catch(err =>{
res.sendStatus(404);
res.send(err);
console.log(err)
})
.then(data => {
res.send(data);
console.log("Done")
})
})
})
router.get('/latest', (req,res)=>{
fetch('https://disease.sh/v2/all')
.catch(err =>{
res.send("Error Occured")
console.log(err)
})
.then(response =>{
if (response.ok) {
return response.json()
} else {
res.sendStatus(404)
res.json("error: Something is wrong.")
return;
}
})
.then(data => {
res.setHeader("Content-Type", "image/jpeg");
getIt(data, "true", "","ig")
.catch(err =>{
res.sendStatus(404);
res.send(err);
console.log(err)
})
.then(data => {
res.send(data);
console.log("Done")
})
})
})
module.exports = router