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

【refactor】Refactoring Request with Axios #65

Closed
Molunerfinn opened this issue Jan 18, 2021 · 8 comments
Closed

【refactor】Refactoring Request with Axios #65

Molunerfinn opened this issue Jan 18, 2021 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@Molunerfinn
Copy link
Member

Molunerfinn commented Jan 18, 2021

Since the package request was deprecated, PicGo-Core will replace it with axios which is active and maintained.

The timeline is the following:

  • v1.5.0: replace the request with axios, but the API exposed to the outside world is still consistent. You can still use ctx.Request.request. However, it will be warned with deprecated. The new api is ctx.request. And you can still use both the old request options & the new axios options for requesting.
  • v1.6.0: just simply use ctx.request is OK, though the request lib will be changed to axios. And you can't use ctx.Request.request anymore.
  • v2.0.0: will add an adaptor layer for web & node environment.
@Molunerfinn Molunerfinn added the enhancement New feature or request label Jan 18, 2021
@Molunerfinn Molunerfinn self-assigned this Jan 18, 2021
@upupming
Copy link
Member

@Molunerfinn So all the uploaders will have to change their implementation?

@Molunerfinn
Copy link
Member Author

@Molunerfinn So all the uploaders will have to change their implementation?

Yes. In v1.5.0, we will provide both ctx.Reqeust.request & ctx.request for developers to change their implementation. It will be a long time since v1.5.0 upgrade to v1.6.0 so developers can have enough time to upgrade. But in v1.6.0, the ctx.Request.request will be removed.

Before v1.5.0, PicGo-Core will provide a way to install a specific version of plugins.

@upupming
Copy link
Member

@Molunerfinn This is very nice~

@upupming
Copy link
Member

upupming commented Oct 5, 2021

v2.0.0: will add an adaptor layer for web & node environment. In the web env, we will use axios, in the node env, we will use got. But the outside world is still ctx.request.

@Molunerfinn At the present, PicGo CLI (ctx.cmd) and plugin install feature (ctx.pluginHandler) is coupled in PicGo class, all of these only works in node environment, so it will be difficult to support web environment. Also, now that we will migarte axios finally, why not using axios now (axios supports both web and node environment), but using got?

@Molunerfinn
Copy link
Member Author

yes we can use axios

@Molunerfinn Molunerfinn changed the title 【refactor】Refactoring Request with Got 【refactor】Refactoring Request with Axios Sep 2, 2022
@Molunerfinn
Copy link
Member Author

Molunerfinn commented Sep 3, 2022

The next alpha version of PicGo-Core will change request to axios.

For plugin developers:

  1. the old request options will also be available but will not be 100% OK, it's recommend to change to new axios options.
  2. support axios options. However, cause we need to be compatible with the old request options, so if your options do not provide resolveWithFullResponse, the result of ctx.request will be just data. See the following examples:
const res = await ctx.request({
  // other options
  resolveWithFullResponse: true
})

console.log(res) // { status, data,  headers, config, request }

const res2 = await ctx.request({
  // other options
})

console.log(res2) // { ...data }

@Molunerfinn
Copy link
Member Author

v1.5.0-alpha.9 is release

@Molunerfinn
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants