From 4782cf1f38fb66dbd5cd87af50aaf2c0ed8ae91b Mon Sep 17 00:00:00 2001 From: silverwind Date: Mon, 11 Sep 2023 10:25:10 +0200 Subject: [PATCH] Add fetch wrappers, ignore network errors in actions view (#26985) 1. Introduce lightweight `fetch` wrapper functions that automatically sets csfr token, content-type and use it in `RepoActionView.vue`. 2. Fix a specific issue on `RepoActionView.vue` where a fetch network error is shortly visible during page reload sometimes. It can be reproduced by F5-in in quick succession on the actions view page and was also producing a red error box on the page. Once approved, we can replace all current `fetch` uses in UI with this in another PR. --------- Co-authored-by: Giteabot --- contributing/guidelines-frontend.en-us.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contributing/guidelines-frontend.en-us.md b/contributing/guidelines-frontend.en-us.md index dc9eef13..921c2b02 100644 --- a/contributing/guidelines-frontend.en-us.md +++ b/contributing/guidelines-frontend.en-us.md @@ -92,6 +92,12 @@ it's recommended to use `const _promise = asyncFoo()` to tell readers that this is done by purpose, we want to call the async function and ignore the Promise. Some lint rules and IDEs also have warnings if the returned Promise is not handled. +### Fetching data + +To fetch data, use the wrapper functions `GET`, `POST` etc. from `modules/fetch.js`. They +accept a `data` option for the content, will automatically set CSFR token and return a +Promise for a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response). + ### HTML Attributes and `dataset` The usage of `dataset` is forbidden, its camel-casing behaviour makes it hard to grep for attributes.