mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	Use fetch helpers instead of fetch (#27026)
WIP because: - [x] Some calls set a `content-type` but send no body, can likely remove the header - [x] Need to check whether `charset=utf-8` has any significance on the webauthn calls, I assume not as it is the default for json content. - [x] Maybe `no-restricted-globals` is better for eslint, but will require a lot of duplication in the yaml or moving eslint config to a `.js` extension. - [x] Maybe export `request` as `fetch`, shadowing the global.
This commit is contained in:
		@@ -2,6 +2,7 @@
 | 
			
		||||
import {createApp, nextTick} from 'vue';
 | 
			
		||||
import $ from 'jquery';
 | 
			
		||||
import {SvgIcon} from '../svg.js';
 | 
			
		||||
import {GET} from '../modules/fetch.js';
 | 
			
		||||
 | 
			
		||||
const {appSubUrl, assetUrlPrefix, pageData} = window.config;
 | 
			
		||||
 | 
			
		||||
@@ -233,11 +234,11 @@ const sfc = {
 | 
			
		||||
      try {
 | 
			
		||||
        if (!this.reposTotalCount) {
 | 
			
		||||
          const totalCountSearchURL = `${this.subUrl}/repo/search?count_only=1&uid=${this.uid}&team_id=${this.teamId}&q=&page=1&mode=`;
 | 
			
		||||
          response = await fetch(totalCountSearchURL);
 | 
			
		||||
          response = await GET(totalCountSearchURL);
 | 
			
		||||
          this.reposTotalCount = response.headers.get('X-Total-Count');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        response = await fetch(searchedURL);
 | 
			
		||||
        response = await GET(searchedURL);
 | 
			
		||||
        json = await response.json();
 | 
			
		||||
      } catch {
 | 
			
		||||
        if (searchedURL === this.searchURL) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
<script>
 | 
			
		||||
import {SvgIcon} from '../svg.js';
 | 
			
		||||
import {GET} from '../modules/fetch.js';
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
  components: {SvgIcon},
 | 
			
		||||
@@ -123,7 +124,7 @@ export default {
 | 
			
		||||
    },
 | 
			
		||||
    /** Load the commits to show in this dropdown */
 | 
			
		||||
    async fetchCommits() {
 | 
			
		||||
      const resp = await fetch(`${this.issueLink}/commits/list`);
 | 
			
		||||
      const resp = await GET(`${this.issueLink}/commits/list`);
 | 
			
		||||
      const results = await resp.json();
 | 
			
		||||
      this.commits.push(...results.commits.map((x) => {
 | 
			
		||||
        x.hovered = false;
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@ import $ from 'jquery';
 | 
			
		||||
import {SvgIcon} from '../svg.js';
 | 
			
		||||
import {pathEscapeSegments} from '../utils/url.js';
 | 
			
		||||
import {showErrorToast} from '../modules/toast.js';
 | 
			
		||||
import {GET} from '../modules/fetch.js';
 | 
			
		||||
 | 
			
		||||
const sfc = {
 | 
			
		||||
  components: {SvgIcon},
 | 
			
		||||
@@ -190,8 +191,7 @@ const sfc = {
 | 
			
		||||
      }
 | 
			
		||||
      this.isLoading = true;
 | 
			
		||||
      try {
 | 
			
		||||
        const reqUrl = `${this.repoLink}/${this.mode}/list`;
 | 
			
		||||
        const resp = await fetch(reqUrl);
 | 
			
		||||
        const resp = await GET(`${this.repoLink}/${this.mode}/list`);
 | 
			
		||||
        const {results} = await resp.json();
 | 
			
		||||
        for (const result of results) {
 | 
			
		||||
          let selected = false;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user