question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Usage with sails.js

See original GitHub issue

I’m trying to use this api with sails.js, but the response return the trends response data. The controller function looks like this:

googleTrends.interestOverTime({keyword: [req.param('keyword')]})
		.then(function(results){
		 	return res.send(results);
		})
		.catch(function(err){
		  return res.json(err);
		});

Returns this:

image

Is there any way to return the data as json object?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
pat310commented, May 18, 2017

Ohh it looks like there is a return in the first character causing the error. Until I get a fix up, you could JSON.parse(results.slice(1)) (or you might need to .slice(2)). Does that work for you?

0reactions
pat310commented, Aug 18, 2017

Closing this for now. I think for now we should continue to just pass a string and have the user modify it as they see fit. If we start slicing characters from the string and validating that it is proper JSON, it will be harder to maintain (whenever the api changes we would need to check that it hasn’t changed) and if we say that it is not valid JSON, the user will get nothing back when in reality there may be data available in the string that is formatted slightly differently than we were expecting.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Programmatic usage - Sails.js
To create a new Sails app from within a Node.js script, use the Sails constructor. The same constructor can be used to create...
Read more >
Advanced usage - Sails.js
A dictionary of all loaded Sails hooks, indexed by their identity. Use sails.hooks to access properties and methods of hooks you've installed to...
Read more >
Tutorials - Sails.js
Here you can find step-by-step guides for dealing with a few specific Sails use cases. There's a wealth of great information and tutorials...
Read more >
What is Sails? - Sails.js
js. A "back-end web" framework helps you do things like build APIs, serve HTML files, and handle hundreds of thousands of simultaneous users....
Read more >
Features | Sails.js
Sails is built on Node.js, a popular, lightweight server-side technology that allows developers to write blazing fast, scalable network appliations in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found