<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Melanie-Koeln</title>
    <description>The latest articles on DEV Community by Melanie-Koeln (@melaniekoeln).</description>
    <link>https://dev.to/melaniekoeln</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F600611%2F3659a008-8682-4a11-9f40-7cc1ab11b1ab.jpeg</url>
      <title>DEV Community: Melanie-Koeln</title>
      <link>https://dev.to/melaniekoeln</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/melaniekoeln"/>
    <language>en</language>
    <item>
      <title>http.get - different data structure</title>
      <dc:creator>Melanie-Koeln</dc:creator>
      <pubDate>Thu, 25 Mar 2021 15:41:28 +0000</pubDate>
      <link>https://dev.to/melaniekoeln/http-get-different-data-structure-34n0</link>
      <guid>https://dev.to/melaniekoeln/http-get-different-data-structure-34n0</guid>
      <description>&lt;p&gt;Hey, &lt;/p&gt;

&lt;p&gt;I'm trying to download data from a server using http.get.&lt;/p&gt;

&lt;p&gt;For testing I'm using the tour of heroes tutorial. I changed the url to another local source.&lt;br&gt;
The data looks like this:&lt;br&gt;
{&lt;br&gt;
    "current":1, "total":2,"rows":[&lt;br&gt;
        {"field1":1000,"field2":"test1"},&lt;br&gt;
        {"field1":1001,"field2":test2"}&lt;br&gt;
        }&lt;br&gt;
Of course, the code cannot run like this. How can I tell angular to use the rows? Is there a option in the http.get? In the tutorial the command was:&lt;br&gt;
  getHeroes(): Observable {&lt;br&gt;
    return this.http.get(this.heroesUrl)&lt;br&gt;
  }&lt;/p&gt;

&lt;p&gt;Another possibility could be to adjust the data later. Perhaps here:&lt;br&gt;
  getHeroes(): void {&lt;br&gt;
    this.heroService.getHeroes()&lt;br&gt;
        .subscribe(heroes =&amp;gt; this.heroes = heroes );&lt;br&gt;
  }&lt;/p&gt;

&lt;p&gt;Thank you very much for your help in advance :).&lt;/p&gt;

&lt;p&gt;Melanie&lt;/p&gt;

&lt;p&gt;edit: &lt;br&gt;
Received following message in the browser (Entwicklungtools):&lt;br&gt;
core.js:6162 ERROR Error: Error trying to diff '[object Object]'. Only arrays and iterables are allowed&lt;/p&gt;

&lt;p&gt;The datatype may not be right?&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Access api - CORS - failed</title>
      <dc:creator>Melanie-Koeln</dc:creator>
      <pubDate>Sat, 20 Mar 2021 14:59:30 +0000</pubDate>
      <link>https://dev.to/melaniekoeln/access-api-cors-failed-4o5o</link>
      <guid>https://dev.to/melaniekoeln/access-api-cors-failed-4o5o</guid>
      <description>&lt;p&gt;Hi :),&lt;br&gt;
I hope, this is the right place for my question:&lt;br&gt;
In my current project, I’m trying to get data from an api. It is my first angular project, so please excuse my inexperience.&lt;br&gt;
The data is on a server on my pc: &lt;a href="http://localhost:8080/api/v1/xy/list"&gt;http://localhost:8080/api/v1/xy/list&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When I try to access the data with my browers, there is no problem.&lt;br&gt;
But when I implement the connection in my  app.component.ts&lt;br&gt;
this.rowData = this.http.get('&lt;a href="http://localhost:8080/api/v1/xy/list"&gt;http://localhost:8080/api/v1/xy/list&lt;/a&gt;' &lt;br&gt;
it fails. &lt;/p&gt;

&lt;p&gt;Checking the result, following notification  occurred:&lt;br&gt;
Access to XMLHttpRequest at '&lt;a href="http://localhost:8080/api/v1/xy/list"&gt;http://localhost:8080/api/v1/xy/list&lt;/a&gt;' from origin '&lt;a href="http://localhost:4200"&gt;http://localhost:4200&lt;/a&gt;' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.&lt;br&gt;
zone-evergreen.js:2863 GET &lt;a href="http://localhost:8080/api/v1/xy/list"&gt;http://localhost:8080/api/v1/xy/list&lt;/a&gt; net::ERR_FAILED&lt;/p&gt;

&lt;p&gt;I tried to fix it with following adjustment in the C:\Users\Micro\my-app\proxy.conf.json&lt;br&gt;
{&lt;br&gt;
  "/api": {&lt;br&gt;
    "target": "&lt;a href="http://localhost:8080/api/v1/xy/list"&gt;http://localhost:8080/api/v1/xy/list&lt;/a&gt;",&lt;br&gt;
    "secure": false,&lt;br&gt;
    "changeOrigin": true,&lt;br&gt;
    "pathRewrite": {&lt;br&gt;
      "^/api": ""&lt;br&gt;
    }&lt;br&gt;
  }&lt;br&gt;
}&lt;br&gt;
According to this page: &lt;a href="https://levelup.gitconnected.com/fixing-cors-errors-with-angular-cli-proxy-e5e0ef143f85"&gt;https://levelup.gitconnected.com/fixing-cors-errors-with-angular-cli-proxy-e5e0ef143f85&lt;/a&gt;&lt;br&gt;
Starting ng again as follows: ng serve --proxy-config .\proxy.conf.json succeed, but the error stays the same. Still no access to the api.&lt;/p&gt;

&lt;p&gt;Have you any idea what I’m doing wrong?&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
