<?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: Aanchal Chauhan</title>
    <description>The latest articles on DEV Community by Aanchal Chauhan (@aanchal_chauhan_430724679).</description>
    <link>https://dev.to/aanchal_chauhan_430724679</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%2F1579229%2F92b94328-7dd0-4527-b119-1f2d8a253141.jpg</url>
      <title>DEV Community: Aanchal Chauhan</title>
      <link>https://dev.to/aanchal_chauhan_430724679</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aanchal_chauhan_430724679"/>
    <language>en</language>
    <item>
      <title>Building a Nearby Deals App with the ipstack API</title>
      <dc:creator>Aanchal Chauhan</dc:creator>
      <pubDate>Thu, 05 Dec 2024 10:37:09 +0000</pubDate>
      <link>https://dev.to/aanchal_chauhan_430724679/building-a-nearby-deals-app-with-the-ipstack-api-3d1k</link>
      <guid>https://dev.to/aanchal_chauhan_430724679/building-a-nearby-deals-app-with-the-ipstack-api-3d1k</guid>
      <description>&lt;p&gt;Creating personalized apps based on location data is a rewarding challenge for developers. In this tutorial, we'll use the &lt;a href="https://ipstack.com/" rel="noopener noreferrer"&gt;ipstack API&lt;/a&gt; to build an app that shares top nearby deals based on user location. By the end of this guide, you'll have a functioning backend with a simple frontend to showcase location-specific deals.&lt;/p&gt;

&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;The goal:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Fetch user location using the ipstack API.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Match user location with nearby deals stored in a database or API.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Display those deals using a user-friendly UI.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What You’ll Need
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;An ipstack API key.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A backend framework (e.g., Node.js).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Sample data for deals or a deals API (e.g., mock data in JSON).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Optional: A frontend library like React or plain HTML/JavaScript.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To make the tutorial interactive, you can follow along with the ipstack API documentation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Fetch Location Data
&lt;/h2&gt;

&lt;p&gt;Start by integrating the ipstack API to retrieve geolocation data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Example&lt;/strong&gt;&lt;br&gt;
Here’s how to fetch user location data based on an IP address:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const axios = require('axios');

const getLocation = async (ipAddress) =&amp;gt; {
  const API_KEY = 'your_ipstack_api_key';
  const url = `http://api.ipstack.com/${ipAddress}?access_key=${API_KEY}`;

  try {
    const response = await axios.get(url);
    const data = response.data;
    console.log('User Location:', data);
    return {
      city: data.city,
      region: data.region_name,
      country: data.country_name,
      latitude: data.latitude,
      longitude: data.longitude,
    };
  } catch (error) {
    console.error('Error fetching location:', error.message);
  }
};

// Example usage:
getLocation('172.70.143.208');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Sample Response&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "ip": "172.70.143.208",
  "city": "Singapore",
  "region_name": "Central Singapore",
  "country_name": "Singapore",
  "latitude": 1.287950038909912,
  "longitude": 103.8517837524414
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Create a Mock Deals Database
&lt;/h2&gt;

&lt;p&gt;To keep things simple, let’s use a JSON file to store some sample deals.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;deals.json&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
  {
    "id": 1,
    "title": "20% off Electronics",
    "city": "Singapore",
    "latitude": 1.290270,
    "longitude": 103.851959
  },
  {
    "id": 2,
    "title": "Buy 1 Get 1 Free - Coffee",
    "city": "Singapore",
    "latitude": 1.300270,
    "longitude": 103.860959
  }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3: Match Deals to User Location
&lt;/h2&gt;

&lt;p&gt;We’ll filter deals based on user location using a simple distance formula.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Haversine Formula&lt;/strong&gt;&lt;br&gt;
This formula calculates the distance between two geographic coordinates.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const getDistance = (lat1, lon1, lat2, lon2) =&amp;gt; {
  const toRad = (value) =&amp;gt; (value * Math.PI) / 180;
  const R = 6371; // Radius of Earth in km

  const dLat = toRad(lat2 - lat1);
  const dLon = toRad(lon2 - lon1);
  const a =
    Math.sin(dLat / 2) * Math.sin(dLat / 2) +
    Math.cos(toRad(lat1)) *
      Math.cos(toRad(lat2)) *
      Math.sin(dLon / 2) *
      Math.sin(dLon / 2);
  const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
  return R * c; // Distance in km
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Filter Nearby Deals&lt;/strong&gt;&lt;br&gt;
Here’s how to find deals within a specific radius:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const filterDeals = (userLat, userLon, deals, radius = 10) =&amp;gt; {
  return deals.filter((deal) =&amp;gt; {
    const distance = getDistance(userLat, userLon, deal.latitude, deal.longitude);
    return distance &amp;lt;= radius;
  });
};

// Example usage:
const userLat = 1.287950038909912;
const userLon = 103.8517837524414;

const deals = require('./deals.json');
const nearbyDeals = filterDeals(userLat, userLon, deals, 5);
console.log('Nearby Deals:', nearbyDeals);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Display Deals in the Frontend
&lt;/h2&gt;

&lt;p&gt;You can keep the frontend lightweight or build something dynamic. Here’s an example using plain HTML and JavaScript.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML Example&lt;/strong&gt;&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;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;meta charset="UTF-8"&amp;gt;
  &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
  &amp;lt;title&amp;gt;Nearby Deals&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;h1&amp;gt;Top Deals Near You&amp;lt;/h1&amp;gt;
  &amp;lt;ul id="deals-list"&amp;gt;&amp;lt;/ul&amp;gt;
  &amp;lt;script&amp;gt;
    const deals = [
      { title: "20% off Electronics", city: "Singapore" },
      { title: "Buy 1 Get 1 Free - Coffee", city: "Singapore" }
    ];

    const list = document.getElementById('deals-list');
    deals.forEach(deal =&amp;gt; {
      const li = document.createElement('li');
      li.textContent = `${deal.title} - ${deal.city}`;
      list.appendChild(li);
    });
  &amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 5: Connect Backend and Frontend
&lt;/h2&gt;

&lt;p&gt;Create an endpoint to serve the filtered deals and fetch them dynamically in the frontend.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Express.js Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const express = require('express');
const app = express();
const deals = require('./deals.json');

app.get('/api/deals', (req, res) =&amp;gt; {
  const userLat = parseFloat(req.query.lat);
  const userLon = parseFloat(req.query.lon);
  const radius = parseInt(req.query.radius) || 10;

  const nearbyDeals = filterDeals(userLat, userLon, deals, radius);
  res.json(nearbyDeals);
});

app.listen(3000, () =&amp;gt; console.log('Server running on port 3000'));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Helpful Resources
&lt;/h2&gt;

&lt;p&gt;Here are a few links to deepen your understanding:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ipstack.com/documentation" rel="noopener noreferrer"&gt;ipstack API Documentation&lt;/a&gt;: Comprehensive guide to ipstack API features.&lt;br&gt;
&lt;a href="https://en.wikipedia.org/wiki/Haversine_formula" rel="noopener noreferrer"&gt;Haversine Formula Explained&lt;/a&gt;: Learn the math behind distance calculation.&lt;br&gt;
&lt;a href="https://nodejs.org/en/learn/getting-started/introduction-to-nodejs" rel="noopener noreferrer"&gt;Node.js Official Guide&lt;/a&gt;: Explore Node.js essentials.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>api</category>
      <category>programming</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Streamline Your Workflow with Numverify's Zapier Integration</title>
      <dc:creator>Aanchal Chauhan</dc:creator>
      <pubDate>Wed, 05 Jun 2024 09:52:06 +0000</pubDate>
      <link>https://dev.to/aanchal_chauhan_430724679/streamline-your-workflow-with-numverifys-zapier-integration-1cfh</link>
      <guid>https://dev.to/aanchal_chauhan_430724679/streamline-your-workflow-with-numverifys-zapier-integration-1cfh</guid>
      <description>&lt;p&gt;In the fast-paced world of business optimization and automation, every second counts. Whether you’re managing customer data, ensuring accurate communications, or automating tedious tasks, having reliable tools at your disposal is essential. That’s why we’re thrilled to introduce the new &lt;strong&gt;Numverify Zap&lt;/strong&gt;, designed to make phone number validation easier than ever, even for users with no coding experience.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fpoeccnk8t7rbo2umrxiv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fpoeccnk8t7rbo2umrxiv.png" alt="Image description" width="624" height="357"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Numverify?&lt;/strong&gt;&lt;br&gt;
Numverify is a leading API service that provides global phone number validation. With a comprehensive database that supports over 232 countries, Numverify helps businesses verify and format phone numbers in real-time, ensuring data accuracy and improving communication efficiency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introducing the Numverify Zap&lt;/strong&gt;&lt;br&gt;
With our new Numverify Zap, integrating phone number validation into your workflow has never been simpler. This powerful tool seamlessly connects Numverify with any Zapier-enabled application, automating the validation process and saving you valuable time and effort. Whether you’re using CRM systems, email marketing tools, or customer support platforms, the Numverify Zap ensures that your phone data is always accurate and up-to-date.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Ease of Use:&lt;/strong&gt; No coding required. Simply set up the Zap and let it run.&lt;br&gt;
&lt;strong&gt;Real-Time Validation:&lt;/strong&gt; Verify phone numbers instantly to ensure accuracy.&lt;br&gt;
&lt;strong&gt;Global Coverage:&lt;/strong&gt; Supports phone numbers from over 232 countries.&lt;br&gt;
Seamless Integration: Works with a wide range of applications through Zapier.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to Get Started&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Sign Up:&lt;/strong&gt; If you haven’t already, sign up for a Zapier account.&lt;br&gt;
Create a Zap: Navigate to the Numverify &lt;a href="https://zapier.com/apps/numverify/integrations" rel="noopener noreferrer"&gt;integration page&lt;/a&gt; and create a new Zap.&lt;br&gt;
&lt;strong&gt;Configure Your Trigger and Action:&lt;/strong&gt; Select your trigger app and action app, then configure the Numverify validation step.&lt;br&gt;
&lt;strong&gt;Activate Your Zap:&lt;/strong&gt; Turn on your Zap and start automating phone number validation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Use Numverify Zap?&lt;/strong&gt;&lt;br&gt;
Automating phone number validation with Numverify’s Zapier integration provides numerous benefits:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Accuracy:&lt;/strong&gt; Reduce errors and ensure data consistency.&lt;br&gt;
&lt;strong&gt;Efficiency:&lt;/strong&gt; Save time by automating manual validation tasks.&lt;br&gt;
&lt;strong&gt;Scalability:&lt;/strong&gt; Easily handle large volumes of phone numbers across various applications.&lt;br&gt;
&lt;strong&gt;Reliability:&lt;/strong&gt; Trust in Numverify’s robust API for accurate and up-to-date phone number validation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Learn More&lt;/strong&gt;&lt;br&gt;
Ready to take your business automation to the next level? Start using the Numverify Zap today and experience the benefits of seamless phone number validation.&lt;/p&gt;

&lt;p&gt;Read more about automating data security by verifying new phone prospects with Zapier in this blog: &lt;a href="https://blog.apilayer.com/easy-steps-to-automate-data-security-by-verifying-new-phone-prospects-with-zapier/" rel="noopener noreferrer"&gt;Easy Steps to Automate Data Security.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>zapier</category>
      <category>numverify</category>
    </item>
  </channel>
</rss>
