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

Mm 006 creation api functions #10

Merged
merged 19 commits into from
Jul 31, 2024
Merged

Conversation

dorothyynwong
Copy link
Collaborator

##Description of changes - what did you do
added scripts:

script 1: utils/fetchData.ts to fetch API.
This function is reusable.
We implemented the use of the .env variable for the apiKey.

input:
a string for API url (without the final part containing the key) e.g. "https://api.nasa.gov/planetary/apod?api_key="
need a .env file in the root directory. inside the .env file, it should be something like this REACT_APP_NASA_API_KEY=""

output:
if there is error, return an error page. otherwise, return the JSON got from the API.

script 2: image/DisplayPicture.tsx to call fetchData

output (needs more work):
Option 1: if you return a React component (return (<>....</>) you can display specific properties of the Image of The Day.
You can render it as , the example can be found in App.tsx

Option 2: you can return the myPictureData instead (but we still are unsure about how to visualize it).
It will probably need another function so that the developer can choose what property to display accordingly to their need

##Things to Check
[ok ] Have all the requirements of your ticket have been met
[n/a] Have you added tests if needed for your ticket
[n/a ] Are all the tests passing

Copy link
Contributor

@Kiran-R-K Kiran-R-K left a comment

Choose a reason for hiding this comment

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

It's looking really good - I've requested a couple of changes - mostly removing comments

.env.template Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you accidentally deleted this file - please can you recreate it - as it's needed for the codebase

src/App.tsx Outdated
import './App.scss';
import Home from './Home/Home';
// line below is just an example of what to import to use the DisplayPictureOfDay function
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove these comments and the the before merging - they might be confusing for some people


const pictureData = await fetchAPI("https://api.nasa.gov/planetary/apod?api_key=");

// test picture data for when the API requests have reached their limit:
Copy link
Contributor

@Kiran-R-K Kiran-R-K Jul 31, 2024

Choose a reason for hiding this comment

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

Please remove this from this PR as it's not for production.


return myPictureData;

// example of how to pick specific properties
Copy link
Contributor

Choose a reason for hiding this comment

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

please remove these comments from this review for clarity

Copy link
Contributor

@Kiran-R-K Kiran-R-K left a comment

Choose a reason for hiding this comment

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

Looks great - really nice work on this

@dorothyynwong dorothyynwong merged commit e371ef6 into main Jul 31, 2024
1 check passed
@dorothyynwong dorothyynwong deleted the mm-006-creation-api-functions branch July 31, 2024 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants