1

Alright, so this sounds like a weird question. I am using yahoo weather API, and discord.js to make a weather command. I use YQL and WOIED to try to have someone enter in their place they want to search up. Here is the variable search:

const query = new YQL(`SELECT * FROM weather.forecast WHERE woeid in (SELECT woeid FROM geo.places(1) WHERE text= ${place})`)

When I use the variable input though, it does not work, and will give me this error:

Cannot read property 'results' of undefined

Now, when I manually input the place I want to see, it works. Here is what I mean:

const query = new YQL(`SELECT * FROM weather.forecast WHERE woeid in (SELECT woeid FROM geo.places(1) WHERE text= "Broomfield, Co")`)

Note that I have my main emphasis on the WHERE text = portion of each search query

Any help would be greatly appreciated!

Swoods23
  • 373
  • 2
  • 5
  • 12

2 Answers2

1

Unless the variable you are inserting has double quotes as part of the string, you are going to have to insert them yourself in the format string. For example:

const query = new YQL(`SELECT * FROM weather.forecast WHERE woeid in (SELECT woeid FROM geo.places(1) WHERE text= "${place}")`)
jaredkwright
  • 1,390
  • 2
  • 11
  • 27
0

It looks like there is something wrong with the place variable. You could try doing

console.log(`place: ${place}`);

before you initialize your query to see what's wrong with it. It could be improperly formatted (e.g. "Broomfield, Colorado"), or it could contain nothing at all.

bluecereal
  • 453
  • 4
  • 6