<?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: Lucca Biagi de Paula Prado</title>
    <description>The latest articles on DEV Community by Lucca Biagi de Paula Prado (@luccabiagi).</description>
    <link>https://dev.to/luccabiagi</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%2F216176%2F163af04e-ecb1-4a27-8b6d-19ee3c9595e3.jpeg</url>
      <title>DEV Community: Lucca Biagi de Paula Prado</title>
      <link>https://dev.to/luccabiagi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/luccabiagi"/>
    <language>en</language>
    <item>
      <title>Creating an geolocation app</title>
      <dc:creator>Lucca Biagi de Paula Prado</dc:creator>
      <pubDate>Mon, 07 Nov 2022 21:55:16 +0000</pubDate>
      <link>https://dev.to/luccabiagi/creating-an-geolocation-app-3l29</link>
      <guid>https://dev.to/luccabiagi/creating-an-geolocation-app-3l29</guid>
      <description>&lt;p&gt;Hi! In this tutorial I'll (try to) teach a little about connecting to rapidAPI apis and mainly creating an app that returns a list of places in defined range, so at the end of this tutorial, you will have an ionic app that can get user coordinates and list places in range.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is RapidAPI hub?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://rapidapi.com/hub" rel="noopener noreferrer"&gt;RapidApi Hub is an &lt;/a&gt; is an online marketplace of rest APIs, in there it's possible to find APIs about almost anything. I strongly advice to take sometime to have a look on it, in there you'll find a lot of cool stuff for your own projects. In this post I'll use my own API &lt;a href="https://rapidapi.com/lumon13/api/geolocation-utils1" rel="noopener noreferrer"&gt;Geolocation-Utils&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Near me application
&lt;/h2&gt;

&lt;p&gt;In this tutorial, we'll use &lt;a href="https://ionicframework.com/" rel="noopener noreferrer"&gt;Ionic (Angular flavor)&lt;/a&gt; as it is multi platform. The main objective is build an application that is capable of get user coordinates and exhibit the response of requests.&lt;/p&gt;

&lt;p&gt;To generate the base application, simply (and after &lt;a href="https://ionicframework.com/docs/intro/cli" rel="noopener noreferrer"&gt;installing the cli&lt;/a&gt;) run:&lt;br&gt;
&lt;code&gt;ionic start XyzNearMe list&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;After running that, you'll have an application that looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxidb9l2nti9fa7vetm20.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxidb9l2nti9fa7vetm20.png" alt="Base List application"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ok, it's nice (thanks Ionic!) but isn't exactly what we want, so let start modding this base!&lt;/p&gt;

&lt;p&gt;On our home component we need to get user coordinates. To do that we can user the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition" rel="noopener noreferrer"&gt;browser api&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;I used it in this way (I'll definitely rename this functions):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ngOnInit() {
        const userLocationConfig = {
            enableHighAccuracy: true,
            timeout: 5000,
            maximumAge: 0
        };
        navigator.geolocation.getCurrentPosition((suc) =&amp;gt; this.manipulateUserCoordinate(suc),
            this.errorAcquiringLocation, userLocationConfig);
    }

    manipulateUserCoordinate(pos) {
        const crd = pos.coords;
        this.lat = crd.latitude;
        this.lon = crd.longitude;
    }

    errorAcquiringLocation(err) {
        console.warn(`ERROR(${err.code}): ${err.message}`);
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So it is really simple to acquire the user coordinates. Here I used it on &lt;code&gt;OnInit&lt;/code&gt; to be sure that it is called when component loads, aside that, it's worth mentioning that I used the &lt;code&gt;manipulateUserCoordinate&lt;/code&gt; as an arrow function to keep my acessibility to &lt;code&gt;this.lat&lt;/code&gt; and &lt;code&gt;this.lon&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Ok, now we have our coordinates, so we can make requests using that. As we created our project using the "list" option, we can took advantage of boilerplate code. &lt;/p&gt;

&lt;p&gt;I started refactoring the &lt;code&gt;getMessages&lt;/code&gt; to &lt;code&gt;getPlaces&lt;/code&gt; and included latitude and longitude as parameters and removed the list making. So it got something like that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public getPlaces(lat: number, lon: number){

    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After I got this method to be called after acquiring user position, I started to mod it including the request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public getPlaces(lat: number, lon: number, distance: number) {
        const httpOptions = {
            headers: new HttpHeaders({
                'X-RapidAPI-Host': 'geolocation-utils1.p.rapidapi.com',
                'X-RapidAPI-Key': 'MY_KEY'
            })
        };

        return this.httpClient.get&amp;lt;any&amp;gt;(`https://geolocation-utils1.p.rapidapi.com/place/search/list?distance=5&amp;amp;lon=${lon}&amp;amp;lat=${lat}`, httpOptions);
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But there's an important step, I created all classes to map properly this response (they can be found at this &lt;a href="https://github.com/LuccaPrado/RecyclingNearMe" rel="noopener noreferrer"&gt;project repo&lt;/a&gt;). So now, I'm returning an Observable of PlaceResponse.&lt;/p&gt;

&lt;p&gt;So in our home component we use our html like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;app-place *ngFor="let place of placeResp" [place]="place"&amp;gt;&amp;lt;/app-place&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and the place component (that you can get by refactoring message component name) is like that now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;ion-item *ngIf="place" [detail]="false"&amp;gt;
  &amp;lt;ion-label class="ion-text-wrap"&amp;gt;
    &amp;lt;h2&amp;gt;
      {{ place.content.name }}
      &amp;lt;span class="date"&amp;gt;
        &amp;lt;ion-note&amp;gt;{{ place.distance.value | number: '1.1-1'}}KM&amp;lt;/ion-note&amp;gt;
      &amp;lt;/span&amp;gt;
    &amp;lt;/h2&amp;gt;
    &amp;lt;h3&amp;gt;{{ place.content.address }}&amp;lt;/h3&amp;gt;
  &amp;lt;/ion-label&amp;gt;
  &amp;lt;/ion-item&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now it looks almost like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvsd0kplwhtopt0l32n7r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvsd0kplwhtopt0l32n7r.png" alt="Final app look like this"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So now we have an app that acquires user location, does an request and display its result on list. I created this tutorial because for me, this is complicated, and I only got to get this running after a few days, so I hope that this helps a little who is trying to do something with Ionic and Angular.&lt;/p&gt;

&lt;p&gt;You can get the final version of code here on my &lt;a href="https://github.com/LuccaPrado/RecyclingNearMe" rel="noopener noreferrer"&gt;github repo&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ionic</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Have you ever used ArangoDb? Why? Why not?</title>
      <dc:creator>Lucca Biagi de Paula Prado</dc:creator>
      <pubDate>Thu, 25 Aug 2022 20:33:07 +0000</pubDate>
      <link>https://dev.to/luccabiagi/have-you-ever-used-arangodb-why-why-not-b5n</link>
      <guid>https://dev.to/luccabiagi/have-you-ever-used-arangodb-why-why-not-b5n</guid>
      <description>&lt;p&gt;Hi! I recently came across &lt;a href="https://www.arangodb.com/"&gt;ArangoDb&lt;/a&gt; and used in some POCs, but I really want to know if someone here already used it in a Real World environment or even if chose to not use in a production environment. So... have you ever used ArangoDb? Why? Why not?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>database</category>
    </item>
    <item>
      <title>Trying an new framework without internet</title>
      <dc:creator>Lucca Biagi de Paula Prado</dc:creator>
      <pubDate>Sat, 29 Feb 2020 16:29:51 +0000</pubDate>
      <link>https://dev.to/luccabiagi/trying-an-new-framework-without-internet-532m</link>
      <guid>https://dev.to/luccabiagi/trying-an-new-framework-without-internet-532m</guid>
      <description>&lt;h1&gt;
  
  
  What?
&lt;/h1&gt;

&lt;p&gt;I'm a backend developer and I'm working on a new personal project, the rest API is almost done and I thought "It's time to make my app". As it is one of my dreams, I concluded "Do it all by myself", but, I just know a little bit of Angular and just it, meanwhile, I started my search for an cool framework that even working with angular would look as mobile app.&lt;/p&gt;

&lt;p&gt;When my hopes was already lost, I found the incredible, &lt;a href="https://onsen.io/"&gt;Onsen Ui&lt;/a&gt; an beautiful "way" to achieve my goal.&lt;br&gt;
I found it just in the night before an three-day weekend in my country, that i would travel to my country house, where, we don't have internet or mobile signal, it's just the place to 'recharge the battery".&lt;/p&gt;

&lt;h1&gt;
  
  
  How?
&lt;/h1&gt;

&lt;p&gt;As I would be offline for some days, I started the preparation, that is, downloading all sample and documentation (that don't have pdf avalaible, i was forced to download pages from their website) that was possible and obviously, run npm install on my starter project.&lt;/p&gt;

&lt;p&gt;Then it began... I noticed that their tutorial is really simple and started to make some fields and the tabs, but, the problem started when I was trying to consume my local api. &lt;/p&gt;

&lt;p&gt;CORS... I was intrigued, because, on the response header the cors header was present and I faced the problem that is &lt;strong&gt;we are Google and Stack Overflow addicted&lt;/strong&gt; there was no one that could help me offline. Tried for hours to change the way that I was including my cors header on api. Finally I got my mistake.&lt;/p&gt;

&lt;p&gt;I was passing the wrong url and the browser just saying that was Cors error, but actually was an "you are dumb" error. Fixed that and my journey continued, until the first epic was complete.&lt;/p&gt;

&lt;h1&gt;
  
  
  What I Learned?
&lt;/h1&gt;

&lt;p&gt;I faced a lot of errors (the saddest one was the "cors" that was not cors) and managed to fix them without help, then I realized that this is the real way to learn, If I was on internet, would took some hours to make what I spent 2 days to do, but, if I tried this again in one or two weeks, I would re-spend this time, because wouldn't be me resolving problems, would be the internet.&lt;/p&gt;

&lt;p&gt;The point is, we are starting to loose control about what we need to search and what we can think about to solve. If you, reading that, really want to know some new tech, download the docs, set an goal and go offline.&lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;

</description>
      <category>angular</category>
      <category>codenewbie</category>
      <category>onseui</category>
      <category>offline</category>
    </item>
  </channel>
</rss>
