Redux saga uses the prompt type mismatch in axios,TS

api.tsx

import http from "./http"

export default {
  common: {
    login(username: string, password: string) {
      return http.post("/common/login", {
        username,
        password,
      })
    },
}

where http is the axios configured encapsulated export.
then you can"t take parameters with you when you write an axios request in saga. How do I write
?

Jul.05,2022

functions that return Promise can be directly yield in the Effect of D.Va encapsulated by Redux and Redux-Saga . In this example, it can be written as:

const res = yield api.common.login(defaultState.username, defaultState.password);

so it is speculated that Redux-Saga itself should also be supported.

however, the problem is that the yield keyword of the current version of TypeScript does not support type inference. In this case, the type of res will be any.

Menu