<?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: John Michael Biddulph</title>
    <description>The latest articles on DEV Community by John Michael Biddulph (@jbiddulph).</description>
    <link>https://dev.to/jbiddulph</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%2F387256%2Ffc5d200a-d645-4039-ae21-f1815ee22fb1.png</url>
      <title>DEV Community: John Michael Biddulph</title>
      <link>https://dev.to/jbiddulph</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jbiddulph"/>
    <language>en</language>
    <item>
      <title>@click to a method in Nuxt using mapbox in a popup</title>
      <dc:creator>John Michael Biddulph</dc:creator>
      <pubDate>Mon, 18 Dec 2023 14:58:44 +0000</pubDate>
      <link>https://dev.to/jbiddulph/click-to-a-method-in-nuxt-using-mapbox-in-a-popup-4gen</link>
      <guid>https://dev.to/jbiddulph/click-to-a-method-in-nuxt-using-mapbox-in-a-popup-4gen</guid>
      <description>&lt;p&gt;I am using MapBox in my NUXT 3 project. In my code, I have 2 popups. I am trying to call a method &lt;strong&gt;openDrawer&lt;/strong&gt; to log something to the console, this doesn't seem to be working?! please help&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;script setup&amp;gt;
import { ref, onMounted, reactive } from 'vue';
import mapboxgl from 'mapbox-gl';

const accessToken = ref("");
const map = ref(null);
const drawer = ref(false);
const markers = reactive({}); // Reactive object to store marker information

onMounted(() =&amp;gt; {
  createMap();
  addMarkers();
});

const createMap = () =&amp;gt; {
  accessToken.value = "xxxxxxxxxx";
  mapboxgl.accessToken = accessToken.value;
  map.value = new mapboxgl.Map({
    container: "map",
    style: "mapbox://styles/mapbox/light-v11",
    zoom: 11,
    center: [107.61861, -6.90389],
  });
}

const addMarkers = () =&amp;gt; {
  const markerData = [
    { id: 1, lngLat: [107.61861, -6.90389], popupContent: 'Marker 1' },
    { id: 2, lngLat: [107.62, -6.9], popupContent: 'Marker 2' },
    // Add more marker data as needed
  ];

  markerData.forEach(data =&amp;gt; {
    const { id, lngLat, popupContent } = data;

    // Create a marker
    const marker = new mapboxgl.Marker()
      .setLngLat(lngLat)
      .addTo(map.value);

    // Create a popup for each marker
    const popup = new mapboxgl.Popup({ offset: 25 })
      .setHTML(`
        &amp;lt;h3&amp;gt;${popupContent}&amp;lt;/h3&amp;gt;
        &amp;lt;p&amp;gt;This is a popup.&amp;lt;/p&amp;gt;
        &amp;lt;button @click="openDrawer(id)"&amp;gt;Click me!&amp;lt;/button&amp;gt;
      `);

    // Add a popup to the marker
    marker.setPopup(popup);

    // Store marker information in the reactive object
    markers[id] = { marker, lngLat, popupContent };
  });
}

const openDrawer = (markerId) =&amp;gt; {
  // Use markers[markerId] to access information about the clicked marker
  const clickedMarker = markers[markerId];
  drawer.value = !drawer.value;
  console.log('Clicked Marker Information:', clickedMarker);
}
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>vue</category>
    </item>
    <item>
      <title>req.userId is undefined</title>
      <dc:creator>John Michael Biddulph</dc:creator>
      <pubDate>Thu, 22 Sep 2022 10:05:49 +0000</pubDate>
      <link>https://dev.to/jbiddulph/requserid-is-undefined-3c6h</link>
      <guid>https://dev.to/jbiddulph/requserid-is-undefined-3c6h</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import jwt from "jsonwebtoken";

const secret = "test";
const auth = async (req, res, next) =&amp;gt; {
  try {
    const token = req.headers.authorization.split(" ")[1];
    const isCustomAuth = token.length &amp;lt; 500;
    let decodedData;
    if (token &amp;amp;&amp;amp; isCustomAuth) {
      decodedData = jwt.verify(token, secret);
      req.userId = decodedData?.id;
    }
    console.log("decodedData: " + decodedData);
    next();
  } catch (error) {
    console.log(error);
  }
};

export default auth;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>react</category>
    </item>
    <item>
      <title>How can I use state in another component?</title>
      <dc:creator>John Michael Biddulph</dc:creator>
      <pubDate>Sat, 16 May 2020 08:24:33 +0000</pubDate>
      <link>https://dev.to/jbiddulph/how-can-i-use-state-in-another-component-2cfl</link>
      <guid>https://dev.to/jbiddulph/how-can-i-use-state-in-another-component-2cfl</guid>
      <description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;So I have my state setup in my main component, I have a TextInput with setState I would like to put into a separate screen (which means a new component). What is the best way to do this?&lt;/p&gt;

&lt;p&gt;Thanks&lt;/p&gt;

&lt;p&gt;John&lt;/p&gt;

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