-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from donoftime2018/backend
Backend
- Loading branch information
Showing
7 changed files
with
168 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,5 +1,24 @@ | ||
<template> | ||
<h1 class="text-blue-600 dark:text-blue-500"> | ||
Dashboard | ||
</h1> | ||
</template> | ||
{{trainData}} | ||
</template> | ||
|
||
<script> | ||
import { onMounted } from "vue"; | ||
import axios from "axios"; | ||
export default { | ||
data() { | ||
return { | ||
trainData: [] | ||
}; | ||
}, | ||
mounted() { | ||
console.log("Mounted!") | ||
axios.get("http://localhost:5118/api/getJsonData").then(response => { | ||
console.log(response); | ||
this.trainData = response.data | ||
}) | ||
} | ||
} | ||
</script> |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System.Threading.Tasks; | ||
using Newtonsoft.Json; | ||
using System.Net.Http; | ||
using System.Xml; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace webapi.Controllers | ||
{ | ||
[Route("api/getJsonData")] | ||
[ApiController] | ||
public class ApiController : ControllerBase | ||
{ | ||
[HttpGet] | ||
public async Task<ActionResult<String>> GetData() | ||
{ | ||
using (HttpClient client = new HttpClient()) | ||
{ | ||
HttpResponseMessage res = await client.GetAsync("https://lapi.transitchicago.com/api/1.0/ttarrivals.aspx?key=f3668ac334484bc88b6b2e7778a013bd&mapid=40380"); | ||
|
||
if (res.IsSuccessStatusCode) | ||
{ | ||
string XMLData = await res.Content.ReadAsStringAsync(); | ||
XmlDocument xmlDoc = new XmlDocument(); | ||
xmlDoc.LoadXml(XMLData); | ||
string jsonData = JsonConvert.SerializeXmlNode(xmlDoc); | ||
return Ok(jsonData); | ||
} | ||
|
||
else | ||
{ | ||
return StatusCode((int)res.StatusCode, "Error fetching XML data"); | ||
} | ||
} | ||
|
||
} | ||
|
||
|
||
} | ||
} |
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
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
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