Daddy-s-Dungeons-Tools / Daddy-s-Dungeons-Tools/ddtools-web

Fetch items from 5etools

Open
#10 1 comment 0 reactions 1 assignee Claimed by @reersa View on GitHub
enhancement P1 web app
Dominant language
TypeScript
Stars
2
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Regardless of how #8, we will need to fetch item data (and other data) from 5etools and convert it to a format we want. We need to do this in Typescript inside of the React app.

Our requirements:
- [ ] fetch `https://5etools-mirror-1.github.io/data/items-base.json`
- [ ] apply the following filters locally
- [ ] "Vanilla" sources
- [ ] no generic variants
- [ ] `map` the data to objects that match the `Item` interface in `ddtools-types`

This should be done in a new file `frontend/src/services/data.ts` in a function called `fetchItems` that can look like the following:

```ts
import { Item } from "ddtools-types";

export async function fetchItems(): Promise {
const url = "https://5etools-mirror-1.github.io/data/items-base.json";

const response = await window.fetch(url);
const data = await response.json(); // This will be the exact JSON data from 5etools with every item

// Filter out stuff from `data` and then map it to new objects in the `Item` format
const items = ???;

return items;
}
```

To accomplish this you'll have to familiarize yourself with:
- Typescript types and syntax
- Javascript promises and async/await
- Functional programming like using `map` on an array

Google these things or ask me about them. Good luck!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.