0

I have created this endpoint

https://jokerleb.com/wp-json/wp/v2/ads/

and the images of any ad are located in

https://jokerleb.com/wp-json/wp/v2/media?parent=24408 // ads id=24408  

Is it possible to return one array containing both endpoints so I can subscribe to only one url in Ionic 3?

Something like this

    this.HttpClient.get(someurl)
      .subscribe(res => {
        this.ads = this.ads.concat(res);
})

I just want to know if I can combine the endpoints above into one, so that I only have one array to work with. Because I need the thumbnails for the ads and I hate that I have to do two requests to get it.

  • 1
    And how did you you create that custom endpoint? Show us your code. – Krzysiek Dróżdż Jul 17 '18 at 6:04
  • @KrzysiekDróżdż I used wordpress.org/plugins/wp-rest-api-controller which did it automatically. But if I can figure out how to combine lets say https://jokerleb.com/wp-json/wp/v2/posts with media url then I can do the same with ads – Lynob Jul 17 '18 at 9:01
  • Issue solved stackoverflow.com/a/51390331/1920003 But it would still be nice to be able to combine both endpoints. If you only know how much troubles this api has caused and sleepless nights... – Lynob Jul 17 '18 at 21:34
  • @Lynob by using a plugin you severely limit your options outside of what the plugin allows you to do. By making the handful of things easy that the plugin enables, you basically eliminate all other things the plugin can't do. There are other ways to do this, but right now nobody can answer questions about those endpoints without an expert level understanding of how WP Rest API Controller works. It severely restricts your ability to find help. Having said that if this was just a normal REST API endpoint, you could have asked "How to extend REST API response?" which is much easier to answer – Tom J Nowell Feb 4 at 0:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.