{"action":"created","issue":{"url":"https://api.github.com/repos/kentcdodds/babel-plugin-preval/issues/64","repository_url":"https://api.github.com/repos/kentcdodds/babel-plugin-preval","labels_url":"https://api.github.com/repos/kentcdodds/babel-plugin-preval/issues/64/labels{/name}","comments_url":"https://api.github.com/repos/kentcdodds/babel-plugin-preval/issues/64/comments","events_url":"https://api.github.com/repos/kentcdodds/babel-plugin-preval/issues/64/events","html_url":"https://github.com/kentcdodds/babel-plugin-preval/issues/64","id":391998919,"node_id":"MDU6SXNzdWUzOTE5OTg5MTk=","number":64,"title":"[question] Using objects as template placeholders","user":{"login":"rtm619","id":20684152,"node_id":"MDQ6VXNlcjIwNjg0MTUy","avatar_url":"https://avatars1.githubusercontent.com/u/20684152?v=4","gravatar_id":"","url":"https://api.github.com/users/rtm619","html_url":"https://github.com/rtm619","followers_url":"https://api.github.com/users/rtm619/followers","following_url":"https://api.github.com/users/rtm619/following{/other_user}","gists_url":"https://api.github.com/users/rtm619/gists{/gist_id}","starred_url":"https://api.github.com/users/rtm619/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rtm619/subscriptions","organizations_url":"https://api.github.com/users/rtm619/orgs","repos_url":"https://api.github.com/users/rtm619/repos","events_url":"https://api.github.com/users/rtm619/events{/privacy}","received_events_url":"https://api.github.com/users/rtm619/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-18T05:09:17Z","updated_at":"2018-12-18T05:12:25Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nI was trying out preval with NextJS to inline my data during build time.\r\n\r\nThis is my code:\r\n\r\n```\r\nstatic async getInitialProps() {\r\n    const { data } = await Axios.get(\r\n      \"http://localhost:3100/graphql?query={ articles{ name slug } }\"\r\n    );\r\n// data.data is an object\r\n    const actualData = preval`\r\n    const allArticles = ${data.data}\r\n    module.exports = allArticles\r\n    `;\r\n    console.log(actualData);\r\n    return { data };\r\n  }\r\n```\r\n\r\nWhen I console log it, it returns an empty object. Am I doing something wrong here? "},"comment":{"url":"https://api.github.com/repos/kentcdodds/babel-plugin-preval/issues/comments/448098741","html_url":"https://github.com/kentcdodds/babel-plugin-preval/issues/64#issuecomment-448098741","issue_url":"https://api.github.com/repos/kentcdodds/babel-plugin-preval/issues/64","id":448098741,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0ODA5ODc0MQ==","user":{"login":"kentcdodds","id":1500684,"node_id":"MDQ6VXNlcjE1MDA2ODQ=","avatar_url":"https://avatars0.githubusercontent.com/u/1500684?v=4","gravatar_id":"","url":"https://api.github.com/users/kentcdodds","html_url":"https://github.com/kentcdodds","followers_url":"https://api.github.com/users/kentcdodds/followers","following_url":"https://api.github.com/users/kentcdodds/following{/other_user}","gists_url":"https://api.github.com/users/kentcdodds/gists{/gist_id}","starred_url":"https://api.github.com/users/kentcdodds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kentcdodds/subscriptions","organizations_url":"https://api.github.com/users/kentcdodds/orgs","repos_url":"https://api.github.com/users/kentcdodds/repos","events_url":"https://api.github.com/users/kentcdodds/events{/privacy}","received_events_url":"https://api.github.com/users/kentcdodds/received_events","type":"User","site_admin":false},"created_at":"2018-12-18T05:12:25Z","updated_at":"2018-12-18T05:12:25Z","author_association":"OWNER","body":"Hi @rtm619,\r\n\r\nRemember that preval happens when your build tool compiles your code. So when you actually run the code, preval has already done its thing and is out of your code. So attempting to make your preval code use a value that wont be available until your code is run will not work. From what it looks like you don't need preval here though. You could just rewrite this to be:\r\n\r\n```javascript\r\nstatic async getInitialProps() {\r\n    const { data } = await Axios.get(\r\n      \"http://localhost:3100/graphql?query={ articles{ name slug } }\"\r\n    );\r\n// data.data is an object\r\n    const actualData = data.data\r\n    console.log(actualData);\r\n    return { data };\r\n  }\r\n```"}}
{"actor":{"display_login":"kentcdodds"}}