question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The backend api calls in the frontend should only happen through services

See original GitHub issue

We expect all the backend API calls should happen through a service but currently there exist multiple directives that make http request. This issue focuses on refactoring directives such that they don’t make any HTTP requests.

Tips on how to resolve this issue: Assume a directive makes an http call to URL \someurl\andsomethingmore

  • Check whether there exists any service which makes this calls, if yes then use the existing service in the directive
    • You can do this through git grep "someurl\and" and check for a service.ts file.
  • If there isn’t any existing service that makes this call then create a new *-backend-api.service.ts file and use that service in the directive. The new service should be written in angular, please follow this doc that describes how to write such service.

Please contact @srijanreddy98 if you have any questions about this issue.


PR’s for reference: #8061

To be assigned to a file or for any queries, comment on the thread and tag @DubeySandeep

The files listed below should be refactored with for the expected behavior:

  • core/templates/services/translation-file-hash-loader-backend-api.service.ts @tpapesh
  • core/templates/pages/exploration-editor-page/editor-tab/templates/modal-templates/teach-oppia-modal.controller.ts
  • core/templates/components/entity-creation-services/story-creation.service.ts

Note: For a guide on how to access Oppia’s webpages, see this.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:70 (52 by maintainers)

github_iconTop GitHub Comments

1reaction
JeeveshGargcommented, Nov 25, 2021

Okay, @mridul-netizen please assign me story-creation.service.ts Thanks.

1reaction
DubeySandeepcommented, May 9, 2021

@MohdImran001 I’ve assigned you to extensions/interactions/EndExploration/directives/oppia-interactive-end-exploration.directive.ts, you can use the existing ExplorationSummaryBackendApiService.loadPublicAndPrivateExplorationSummaries function instead of creating a new backend API service. Let me know if you need any help! 😃

@jay24rajput Welcome to Oppia! I’ve assigned you to core/templates/pages/preferences-page/preferences-page.component.ts, you can create a function in the existing UserBackendApiService (instead of creating a new file). Let me know if you need any help! 😃 [I found that core/templates/dev/head/pages/creator-dashboard-page/creator-dashboard-page.controller.ts is already resolved so assigned you to another part of this issue, I hope that’s fine!]

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTPs calls in frontend should only happen through *backend ...
We are expecting to make all the https class from a backend-api.services (like this question-backend-api.service.ts).
Read more >
Should I make 3rd party API calls in backend or frontend?
Generally I would recommend always making the 3rd party calls from the back end. It gives you more control and avoids any cross...
Read more >
Distinction between API and frontend-backend
the API is the agreed way that the front-end and back-end will work together. This is structurally implied with matching code, and explicitly...
Read more >
Where does an API come in on front-end and back-end? - Quora
A REST API service usually comes ad a medium/”interface” for the frontend to consume data served from backend. Sometime even the backend uses...
Read more >
How Does the Frontend Communicate with the Backend?
Once the HTML and JS has arrived at the browser, the JS is executed and starts making requests to the server for DATA....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found