0

I am new to OctoberCMS, I am wondering if it is possible to use http request to fetch data from an external api?

I tried to google this but couldn’t find any results. Maybe I’m searching using the wrong terms.

Can anyone please give me ANY info or tutorials? I know how to do it in PHP but not exactly sure how to integrate it in octobercms and its template page

Thanks

shieldcy
  • 592
  • 2
  • 11
  • 35
  • 1
    can you check this docu: https://octobercms.com/docs/api/october/rain/network/readme it can help you as it has all get, post, put, delete requests for api. – Hardik Satasiya Dec 01 '20 at 07:07
  • Thanks for your reply. How could this be integrated in the twig template? Is it the same procedure as Laravel? Meaning do whatever needs to be done in the controller and return it in the blade template file? – shieldcy Dec 01 '20 at 08:28
  • 1
    you need to read the documentation first for that otherwise you will get a question which is already answered in the documentation, check this https://octobercms.com/docs/cms/pages -> in the code section you can use API calls – Hardik Satasiya Dec 01 '20 at 09:27

1 Answers1

0
  1. Create a routes.php file at the root of your plugin

  2. Add the following code example to the file (routing like in laravel): enter image description here

  3. Open your address and enter localhost/test-request in the address bar