Answers.Body: <p>So your AJAX request likely hit an Element API or GraphQL endpoint, which would return the data to you as JSON.</p>
  
  <p>What exactly that endpoint returns is totally up to the endpoint, but realize that it's not a PHP/Twig object that gets returned. It's a JSON-ified representation of it.</p>
  
  <p>So for you to get the <code>article.relatedTopics</code> either the endpoint would need to have resolved the <code>.relatedTopics</code> and return them as JSON, or it could return an <code>id</code> or other information that you could use in <em>another</em> AJAX request to return that data.</p>
  
  <p>More reading:</p>
  
  <ul>
  <li><a href="https://nystudio107.com/blog/lazy-loading-with-the-element-api-vuejs" rel="nofollow noreferrer">Lazy Loading with the Element API &amp; VueJS</a></li>
  <li><a href="https://nystudio107.com/blog/autocomplete-search-with-the-element-api-vuejs" rel="nofollow noreferrer">Autocomplete Search with the Element API &amp; VueJS</a></li>
  <li><a href="https://nystudio107.com/blog/using-vuejs-graphql-to-make-practical-magic" rel="nofollow noreferrer">Using VueJS + GraphQL to make Practical Magic</a></li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-07T00:25:05.023Z
Answers.LastActivityDate: 2018-09-07T00:25:05.023Z
Answers.UserDisplayName: andrew.welch
Body: <p>For example, in a vuejs component, i send a ajax request to get an article. And in this article, there is a relation field called <code>relatedTopics</code>. </p>
  
  <p>How can I get this article's relatedTopics with something like <code>article.relatedTopics</code>?</p>
  
Tags: <plugin-development><templating><frontend>
Title: How to get one entry's related stuff in Vuejs component
ThreadText: # How to get one entry's related stuff in Vuejs component
  
  (Asked by: username_0 on 2018-09-06)
  
  For example, in a vuejs component, i send a ajax request to get an article. And in this article, there is a relation field called `relatedTopics`.
  
  How can I get this article's relatedTopics with something like `article.relatedTopics`?
  
  **Tags:** plugin-development, templating, frontend
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-09-07. Score: 1
  
  So your AJAX request likely hit an Element API or GraphQL endpoint, which would return the data to you as JSON.
  
  What exactly that endpoint returns is totally up to the endpoint, but realize that it's not a PHP/Twig object that gets returned. It's a JSON-ified representation of it.
  
  So for you to get the `article.relatedTopics` either the endpoint would need to have resolved the `.relatedTopics` and return them as JSON, or it could return an `id` or other information that you could use in *another* AJAX request to return that data.
  
  More reading:
  
  * [Lazy Loading with the Element API & VueJS](https://nystudio107.com/blog/lazy-loading-with-the-element-api-vuejs)
  * [Autocomplete Search with the Element API & VueJS](https://nystudio107.com/blog/autocomplete-search-with-the-element-api-vuejs)
  * [Using VueJS + GraphQL to make Practical Magic](https://nystudio107.com/blog/using-vuejs-graphql-to-make-practical-magic)
  
  
  ---
  
  