AndreasFaust / gatsby-source-custom-api

Source data from any API and transform it to (File-)Nodes.
52 stars 25 forks source link

Add support for env variable urls #4

Closed matt-subroot closed 5 years ago

matt-subroot commented 5 years ago

When I use an environment variable to store my endpoint, I get a type error saying only absolute urls are supported. Please add support for environment variables

matt-subroot commented 5 years ago

I was having a couple issues with this that when combined made the initial debugging difficult.

First, you have to use es5 syntax in the url. For example the string literal http://mydomain.com/users?id=${process.env.SOME_VAR}&group=22 needs to be "http://mydomain.com/users?id="+process.env.SOME_VAR+"&group=22"

Second, your .env file needs to specifically be called .env.development when following documentation for loading the dotenv file into the gatsby.config.

With those two changes in place, this works just fine now. Closing ticket.