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

封装异步的fetch,使用async await方式来使用 #163

Open
Sunny-117 opened this issue Nov 3, 2022 · 2 comments
Open

封装异步的fetch,使用async await方式来使用 #163

Sunny-117 opened this issue Nov 3, 2022 · 2 comments

Comments

@Sunny-117
Copy link
Owner

No description provided.

@GavinZhou0125
Copy link

// 异步方法
async function myFetchAsync(url, options) {
  try {
    //等 获取到数据
    const response = await fetch(url, options);
    if (!response.ok) {
      throw new Error(`${response.status} ${response.statusText}`);
    }
    return response;
  } catch (error) {
    console.error(error);
    throw error;
  }
}

@jacksyk
Copy link

jacksyk commented Aug 12, 2024

没太懂这个题的意思

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

No branches or pull requests

3 participants