Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Add page about fetching data from frontend code using the data proxy #889

Merged
merged 3 commits into from
May 1, 2024

Conversation

academo
Copy link
Member

@academo academo commented Apr 24, 2024

What this PR does / why we need it:

Adds documentation about how to use the data proxy.

This documentation teaches and follow similar concepts to https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/add-authentication-for-data-source-plugins#authenticate-using-the-data-source-proxy but it focuses in general usage for data fetching and not only on authentication. The add authentication page is linked in the sections where authentication is mentioned

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

@academo academo requested a review from a team as a code owner April 24, 2024 08:30
@academo academo requested review from oshirohugo and removed request for a team April 24, 2024 08:30
Copy link

github-actions bot commented Apr 24, 2024

Hello! 👋 This repository uses Auto for releasing packages using PR labels.

✨ This PR can be merged. It will not be considered when calculating future versions of the npm packages and will not appear in the changelogs.

@academo academo requested review from tolzhabayev, marefr, sympatheticmoose and josmperez and removed request for oshirohugo April 24, 2024 08:31
@academo academo self-assigned this Apr 24, 2024
@academo academo added type/docs Changes only affect the documentation no-changelog Don't include in changelog and version calculations labels Apr 24, 2024
Copy link
Member

@marefr marefr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. Some comments to begin with


To fetch data from your data source an app plugins you have two options:

- Use the browser [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) as you would do for any other javascript project
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't you still use fetch even if hitting the Grafana API? Did you intend explaining browser connects directly to service vs grafana api?

Copy link
Member Author

@academo academo Apr 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. When you use the data proxy you use fetch from getBackendSrv. This fetch is the window,fetch from the browser. Though technically you could also simply use the browser fetch but it is best to use the backendSrcv one

@josmperez
Copy link
Contributor

I have edited the PR for style, consistency, structure, and clarity. See commit at 48015df. Please take a look and let me know if you have any questions about any of my suggestions.

@academo
Copy link
Member Author

academo commented Apr 30, 2024

I have edited the PR for style, consistency, structure, and clarity. See commit at 48015df. Please take a look and let me know if you have any questions about any of my suggestions.

Thank you for all the changes and style fixes they look good

@academo academo requested a review from marefr April 30, 2024 07:11
@sympatheticmoose
Copy link
Contributor

Thanks for working on this @academo - afraid I won't be able to review this week. Happy for it to be merged assuming Joe and Marcus we're ok with the content 👍

@sympatheticmoose sympatheticmoose removed their request for review April 30, 2024 08:19
Copy link
Contributor

@josmperez josmperez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@academo academo merged commit b331eb6 into main May 1, 2024
12 checks passed
@academo academo deleted the academo/add-data-proxy-extended-docs branch May 1, 2024 07:36
@marefr
Copy link
Member

marefr commented May 2, 2024

I might have a few more suggestions :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Don't include in changelog and version calculations type/docs Changes only affect the documentation
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants