Uncaught (in promise) SyntaxError: Unexpected end of JSON input

Posted on

getting this error when using fetch to connect to my rails api



in the browser I was able to get to the page




rails action was rendering basic text not json, so I had to change fetch


def description
if product
if product.description
render plain: product.description
render plain: “No description”
end end end


.then(res=>res.text()) //<————————————-


Could not find an executable [“phantomjs”] on your path.

Posted on


Got this error when running rspec.

1.2) Failure/Error:


              Could not find an executable #{@executables} on your path.)


            Could not find an executable [“phantomjs”] on your path.



gem 'phantomjs', :require => 'phantomjs/poltergeist'

I added this to my gem file, under group :development, :test do and ran bundle install

After that this error didnt come up

answer found on

node notes: require() caches module.exports

Posted on Updated on

if you are importing a file that instantiates a new object

when you import the file again as a 2nd object you would expect … a new object

but your 2nd variable will be the same object as the first variable, even though a “new” constructor was used. why?

Node caches module imports , it wont load the file again so no new instance!!!


// file greet3.js
function Greetr(){
  this.greeting=”Hello World from greet3″
module.exports = new Greetr();


var greet3 = require(“./greet3.js”);
greet3.greeting = “NEW GREETING!!!!”
var greet3a = require(“./greet3.js”);
Hello World from greet3
how to resolve??
in the file being exported, greet3.js, send the constructor not the new instance
module.exports = Greetr;
var Greet3a = require(“./greet3.js”);  //you capitalize greet3a to tell its constructor
var grtr = new Greet3a();

Node notes : on require with no js file in local path

Posted on

if you require, for example  “greet”, and greet.js is not found, node will look for folder called “greet” and then look for a file called index.js



Errors encountered on my way to install Node.JS v8 on ubuntu

Posted on

when running apt-get install nodejs

You might want to run ‘apt-get -f install’ to correct these:
The following packages have unmet dependencies:
libgail-3-0 : Depends: libgtk-3-0 (= 3.20.9-1ubuntu2) but 3.18.9-1ubuntu4 is to be installed
nodejs : Depends: libuv1 (>= 1.6.1) but it is not going to be installed
python3-gi-cairo : Depends: python3-gi (= 3.22.0-1) but 3.20.0-0ubuntu1 is to be installed E: Unmet dependencies. Try ‘apt-get -f install’ with no packages (or specify a solution).

to fix:  apt-get -f install

When trying to install nodejs again will only allow for node-legacy (v4)

to fix: 

# Using Ubuntu
curl -sL | sudo -E bash -
sudo apt-get install -y nodejs


finally at v8 locally


io.emit vs socket.emit

Posted on

io.emit lets the server send an event to all the connected clients at once. This is useful when you need to send some data to everyone. This is something we want everyone to be able to see.

socket.emit sends an event to a single socket. This is great when you need to send an event to a single user. Example: This is why we use socket.emit when sending out a greeting message. It only needs to go to that one user. notes

JavaScript Classes review

Posted on Updated on

Some basic notes

// *****START CLASS***********************************************

//The constructor function is called automatically when an instance of the class is created.
// a special method for creating and initializing an object created with a class.
// There can only be one special method with the name “constructor” in a class.
class Person {
constructor (name,age) { //this is a function
// console.log(name,age);
getUserDescription(){return `${} is ${this.age} year(s) old`}

// *****END CLASS***********************************************

var me = new Person(“Andrew”,25); //arguments are passed to constructor function
// console.log(“”,
// console.log(“this.age”, me.age)
var description = me.getUserDescription(); // Andrew is 25 year(s) old

Location object

Posted on Updated on

Contains info about the URL

Part of the window object, also accessible by document object

Can access in dev tools by typing location

Items in location

  • search. : that is the query string 
  • pathname 
  • origin 
  • href 
  • port

See MDN for more
Examples: access seatch use
See stevenbenner jQuery deparam for deconstruction of params  or go here 

Example deparam after loading function 


What is the end goal? Musings on programming.

Posted on

I a doing FreeCodeCamp’s Build a Weather app for the 2nd time. (maybe 3rd? who knows)

This time I thought I would get fancy, try to get the location from HTML5 first, then if an error, get the location from a IP geolocation service.

Well, I am finding that some functions don’t wait for the return of data from another, and rather than having an orchastrator function I would need to chain the functions together.


Original:  master() call geoHTML5; if error master() call geoIP;

now: master() call geoHTML5 call geoIP() call….

Now I could just forgo HTML5 geolocation since IP geolocation works and actually has better data than HTML5 gelocation.

What is my end goal? To finish the project? Then ip geolocation would be the right choice, dont waster time on other things.

But what is my REAL end goal? TO get better at programming and learn the ins and outs of javascropt. That means I need to deal with my original plan and found out how to implement it..

What is the end goal? I’ve already done a weather app. The goal is to get better at programming.