-
-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ronald Holshausen
committed
Sep 28, 2019
1 parent
7683ba8
commit 79082fd
Showing
4 changed files
with
410 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
const express = require('express') | ||
const express = require("express") | ||
const app = express() | ||
const port = 3000 | ||
|
||
app.get('/', (req, res) => res.send('Hello World!')) | ||
app.get("/", (req, res) => res.send("Hello World!")) | ||
|
||
app.listen(port, () => console.log(`Example app listening on port ${port}!`)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,34 @@ | ||
const axios = require('axios') | ||
const parser = require('xml2json') | ||
const eyes = require('eyes') | ||
const axios = require("axios") | ||
const parser = require("xml2json") | ||
const eyes = require("eyes") | ||
|
||
let serverUrl = 'http://localhost:2203' | ||
let serverUrl = "http://localhost:2203" | ||
|
||
module.exports = { | ||
getProjects: async (format = "json") => { | ||
return axios.get(serverUrl + '/projects?from=today', { | ||
headers: { | ||
'Accept': 'application/' + format | ||
} | ||
}) | ||
.then(response => { | ||
console.log("todo response:") | ||
eyes.inspect(response.data) | ||
if (format === 'xml') { | ||
const result = JSON.parse(parser.toJson(response.data)) | ||
return result.projects.project | ||
} else { | ||
return response.data | ||
} | ||
}) | ||
.catch(error => { | ||
console.log("todo error", error.message) | ||
return Promise.reject(error) | ||
}) | ||
return axios | ||
.get(serverUrl + "/projects?from=today", { | ||
headers: { | ||
Accept: "application/" + format, | ||
}, | ||
}) | ||
.then(response => { | ||
console.log("todo response:") | ||
eyes.inspect(response.data) | ||
if (format === "xml") { | ||
const result = JSON.parse(parser.toJson(response.data)) | ||
return result.projects.project | ||
} else { | ||
return response.data | ||
} | ||
}) | ||
.catch(error => { | ||
console.log("todo error", error.message) | ||
return Promise.reject(error) | ||
}) | ||
}, | ||
setUrl: function (url) { | ||
setUrl: function(url) { | ||
serverUrl = url | ||
return this | ||
} | ||
}, | ||
} |
Oops, something went wrong.