/dfwTips

Rudy says where to go when in the Dallas Fort Worth Metroplex. A curated short filtered list as a JSON API.

Primary LanguageJavaScript

dfwTips JSON API

This repository serves as my own API of static JSON data for the creation of google maps markers.

This list curates a list of places to see when in DFW grouped by category.

It's intended to feed a single page React app, but can be used for any reason.

Cheers!

To use

Fetch with Chained Promises

This approach based on this article.

Required Code

See src directory. See fetch-basicBrowswerClient.js

//see https://developers.google.com/web/updates/2015/03/introduction-to-fetch
function status(response) {
    if (response.status >= 200 && response.status < 300) {
        return Promise.resolve(response);
    } else {
        return Promise.reject(new Error(response.statusText));
    }
}

function json(response) {
  return response.json();
}

Example Usage

const DFW_TIPS_API_URL =
'https://rudimusmaximus.github.io/dfwTips/dfwTipsAPI.json';

fetch(DFW_TIPS_API_URL)
  .then(status)
  .then(json)
  .then(  data => console.log(`Request succeeded with JSON response: `, data))
  .catch(error => console.log(`Request failed: `, error));

XMLHttpRequest

Required Code

See src directory. If using a copy of XMLHttpRequest-basicBrowserClient.js

Example Usage

const DFW_TIPS_API_URL = 'https://rudimusmaximus.github.io/dfwTips/dfwTipsAPI.json'

hitApi(DFW_TIPS_API_URL, function(error, data) {
  if (error) {
    console.log('there was an error', error);
  } else {
    console.log('data is', data);
  }
});

The JSON

I curate a list and keep it in a google sheets file here.

master list maintained in a google sheet

I use this sheets add-on to export to JSON: Export Sheet Data sheets add-on

export sheets data add-on

Additional Attributions

Original idea from this article Making a JSON API with GitHub Pages. The add on is open source and can be found on GitHub at: github.com/Synthoid/ExportSheetData

I use this tool to get the lat/lng for the markers using the address of each location.

google maps api geocoder tool