Giter VIP home page Giter VIP logo

congressional-district-finder's People

Contributors

chrisdevwords avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

congressional-district-finder's Issues

TypeError: ... has no method 'find'

I'm trying to include your library in an express project I'm building:

var Promise = require('es6-promise').Promise;
var finder = require('congressional-district-finder');

...

router.get('/coordinate/:latitude/:longitude', function(req, res) {
  var lat = req.params.latitude
  var lng = req.params.longitude
  console.log("Request sent for lat: "+lat+" lng: "+lng)
  finder.getDistrictByLatLng(lat, lng)
      .then(function(result) {
          console.log(result.isMatched); // outputs true
          console.log(result.district.name); //outputs "New York 12th"
          console.log(result.district.districtCode); //outputs "NY-12"
          res.status(200).json({"matched" : result.isMatched, "name" : result.district.name, "code" : result.district.code })
      })
      .catch(function(err) {
        console.log(err);
        res.status(500).send(err.message);
    })
});

However, whenever I access that point, it throws an error:

Request sent for lat: 37.3982430 lng: -121.9922530
[TypeError: Object [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object] has no method 'find']
GET /coordinate/37.3982430/-121.9922530 500 156.947 ms - 171

Any idea about the issue here?

Tried the getDistrictByAddress example and got this:

<html>
<head><base href="https://www.house.gov">
<title>Find Your Representative in the U.S. House of Representatives</title>
<meta charset="UTF-8">
<meta name="robots" content="NOODP">

<link rel="stylesheet" href="/content/static/css/h.css?v=1">
<link rel="stylesheet" href="/content/static/css/house.css?v=1">
<!--[if IE]>
<link rel="stylesheet" href="/content/static/css/ie.css?v=1">
<![endif]-->
<link rel="shortcut icon" href="/content/static/img/favicon.ico" type="image/x-icon">

<script type="text/javascript" src="/content/static/js/jquery.min.js"></script>
<script type="text/javascript" src="/content/static/js/html5lightbox/html5lightbox.js"></script>
<script type="text/javascript" src="/content/static/js/jquery.lightbox.min.js"></script>
<script type="text/javascript" src="/content/static/js/jquery.cycle.all.min.js"></script>
<script type="text/javascript" src="/content/static/js/h.js?v=1"></script>

<script type="text/javascript">

  var _gaq = _gaq || [" is an invalid format.
    at parseDistrictCode (/Users/taylorhammons/capstone-Node/easy-node-authentication/node_modules/house-gov-page-scraper/dist/house/gov/getDistrictsInZip.js:45:15)
    at Array.map (<anonymous>)
    at scrapePage (/Users/taylorhammons/capstone-Node/easy-node-authentication/node_modules/house-gov-page-scraper/dist/house/gov/getDistrictsInZip.js:68:17)
    at /Users/taylorhammons/capstone-Node/easy-node-authentication/node_modules/house-gov-page-scraper/dist/house/gov/getDistrictsInZip.js:84:16
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:9169) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:9169) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

UnhandledPromiseRejectionWarning var _gaq = _gaq || [" is an invalid format.

I tried the example and got this

<html>
<head><base href="https://www.house.gov">
<title>Find Your Representative in the U.S. House of Representatives</title>
<meta charset="UTF-8">
<meta name="robots" content="NOODP">

<link rel="stylesheet" href="/content/static/css/h.css?v=1">
<link rel="stylesheet" href="/content/static/css/house.css?v=1">
<!--[if IE]>
<link rel="stylesheet" href="/content/static/css/ie.css?v=1">
<![endif]-->
<link rel="shortcut icon" href="/content/static/img/favicon.ico" type="image/x-icon">

<script type="text/javascript" src="/content/static/js/jquery.min.js"></script>
<script type="text/javascript" src="/content/static/js/html5lightbox/html5lightbox.js"></script>
<script type="text/javascript" src="/content/static/js/jquery.lightbox.min.js"></script>
<script type="text/javascript" src="/content/static/js/jquery.cycle.all.min.js"></script>
<script type="text/javascript" src="/content/static/js/h.js?v=1"></script>

<script type="text/javascript">

  var _gaq = _gaq || [" is an invalid format.```

District code substring: "" is an invalid format.

Just tried a request to test out the result format, but get an error every time. Changed it to async/await syntax and get the same thing.

This is my JS code

const findUserDistrict = (lat, long) => {
	finder
		.getDistrictByLatLng(lat, long)
		.then(function(result) {
			console.log(result.district.name);
			console.log(result.district.districtCode);
		})
		.catch(function(err) {
			console.log(err.message);
		});
};

findUserDistrict(21.3069, -157.8583);

and this is what I get as a result:

Error: District code substring: "" is an invalid format.
    at parseDistrictCode (/Users/ryan/code/breakdown/breakdown-api/node_modules/house-gov-page-scraper/dist/house/gov/getDistrictsInZip.js:37:15)
    at Array.map (<anonymous>)
    at scrapePage (/Users/ryan/code/breakdown/breakdown-api/node_modules/house-gov-page-scraper/dist/house/gov/getDistrictsInZip.js:68:17)
    at /Users/ryan/code/breakdown/breakdown-api/node_modules/house-gov-page-scraper/dist/house/gov/getDistrictsInZip.js:84:16
    at process._tickCallback (internal/process/next_tick.js:68:7)

Would really appreciate a solution to this, as I'm launching a time-sensitive app for this election.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.