mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-12-29 03:53:14 +03:00
75245747d2
* Initial docs update for Hacktoberfest * Contributing.md update * Update "Before you begin" section * Update web/docs/tutorials/dev-excuses-app/creating-the-project.md Co-authored-by: Martin Šošić <Martinsos@users.noreply.github.com> * Update web/docs/tutorials/dev-excuses-app/updating-main-page-js-file.md Co-authored-by: Martin Šošić <Martinsos@users.noreply.github.com> * Update CONTRIBUTING.md Co-authored-by: Martin Šošić <Martinsos@users.noreply.github.com> * Update web/docs/tutorials/dev-excuses-app/modifying-main-wasp-file.md Co-authored-by: Martin Šošić <Martinsos@users.noreply.github.com> * Update the section names * Update CONTRIBUTING.md Co-authored-by: Matija Sosic <matija.sosic@gmail.com> * Update web/docs/tutorials/dev-excuses-app/updating-main-page-js-file.md Co-authored-by: Matija Sosic <matija.sosic@gmail.com> * Update web/docs/contributing.md Co-authored-by: Matija Sosic <matija.sosic@gmail.com> * Update web/docs/contributing.md Co-authored-by: Matija Sosic <matija.sosic@gmail.com> * Update web/docs/contributing.md Co-authored-by: Matija Sosic <matija.sosic@gmail.com> * Add Discord component and some minor fixes * Add unclear notice * Update web/docs/pick-a-tutorial.md Co-authored-by: Matija Sosic <matija.sosic@gmail.com> * Update web/docs/tutorials/dev-excuses-app.md Co-authored-by: Matija Sosic <matija.sosic@gmail.com> * Update web/docs/tutorials/dev-excuses-app.md Co-authored-by: Matija Sosic <matija.sosic@gmail.com> * Update web/docs/tutorials/dev-excuses-app.md Co-authored-by: Matija Sosic <matija.sosic@gmail.com> * Update CONTRIBUTING.md Co-authored-by: Matija Sosic <matija.sosic@gmail.com> * Update web/docs/tutorials/dev-excuses-app/modifying-main-wasp-file.md Co-authored-by: Matija Sosic <matija.sosic@gmail.com> * Update web/docs/getting-started.md Co-authored-by: Matija Sosic <matija.sosic@gmail.com> * Update web/docs/tutorials/dev-excuses-app/modifying-main-wasp-file.md Co-authored-by: Matija Sosic <matija.sosic@gmail.com> * Review updates * Update web/docs/tutorials/dev-excuses-app/modifying-main-wasp-file.md Co-authored-by: Matija Sosic <matija.sosic@gmail.com> * Update suggestion * Update web/docs/tutorials/dev-excuses-app/perform-migration-and-run.md Co-authored-by: Matija Sosic <matija.sosic@gmail.com> * Update web/docs/tutorials/dev-excuses-app/perform-migration-and-run.md Co-authored-by: Matija Sosic <matija.sosic@gmail.com> * Update * Update web/docs/tutorials/dev-excuses-app/updating-main-page-js-file.md Co-authored-by: Matija Sosic <matija.sosic@gmail.com> * Update CONTRIBUTING.md Co-authored-by: Matija Sosic <matija.sosic@gmail.com> * Remove lines * Update CONTRIBUTING.md Co-authored-by: Matija Sosic <matija.sosic@gmail.com> * Update CONTRIBUTING.md Co-authored-by: Matija Sosic <matija.sosic@gmail.com> * Update CONTRIBUTING.md Co-authored-by: Matija Sosic <matija.sosic@gmail.com> * Update getExcuse function * Update page naming convention * Remove Main.css * Update migration text * Update image * Update "Wasp's compiler is built with Haskell" * Add tutorials description * Update web/docs/pick-a-tutorial.md Co-authored-by: Matija Sosic <matija.sosic@gmail.com> * Update Discord link and tutorial ending * Update links Co-authored-by: mkhamrov <mkhamrov@redhat.com> Co-authored-by: Martin Šošić <Martinsos@users.noreply.github.com> Co-authored-by: Matija Sosic <matija.sosic@gmail.com>
1.1 KiB
1.1 KiB
id | title |
---|---|
03-adding-operations | Adding operations |
import useBaseUrl from '@docusaurus/useBaseUrl';
Now you'll need to create two files: actions.js
and queries.js
in the ext
folder.
Let’s add saveExcuse()
action to our actions.js
file. This action will save the text of our excuse to the database.
export const saveExcuse = async (excuse, context) => {
return context.entities.Excuse.create({
data: { text: excuse.text }
})
}
Then we need to create two queries in the queries.js
file. First, one getExcuse
will call an external API and fetch a new excuse. The second one, named getAllSavedExcuses
, will pull all the excuses we’ve saved to our database.
import axios from 'axios';
export const getExcuse = async () => {
const response = await axios.get('https://api.devexcus.es/')
return response.data
}
export const getAllSavedExcuses = async (_args, context) => {
return context.entities.Excuse.findMany()
}
That’s it! We finished our back-end. 🎉 Now, let’s use those queries/actions on our UI.