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

create needs transform else gives error Could not get default transformRequest function from Axios defaults #477

Open
RupamShaw opened this issue Feb 11, 2022 · 1 comment

Comments

@RupamShaw
Copy link

empty param creating instance in axios

 const client = axios.create()

gives error

  Could not get default transformRequest function from Axios defaults

below code works perfectly when passing tranform


 try {
    const aws4Interceptor = require("aws4-axios").aws4Interceptor


    const client = axios.create({
      transformRequest: (data, headers) => {
        // delete headers.common["Authorization"]
        // console.log(data)
        // console.log(headers)
        return data
      },
    })
    const interceptor = aws4Interceptor(
      {
        region: "us-east-1",
        service: "ivs",
      },
      {
        accessKeyId: AWS_KEY,
        secretAccessKey: AWS_SECRET,
      }
    )

    client.interceptors.request.use(interceptor)

    const currentChannelData = JSON.stringify({
      channelArn: CURRENT_CHANNEL,
    })
    const {data, status} = await client.post(
      `${AWS_URL}/GetStream`,
      currentChannelData
    )

    if (status === 200) {
      console.log(data)
      return data.stream.viewerCount
    }

    throw new Error("Some problem in getWatchingStreamCount.")
  } catch (err) {
    if (err.response && err.response.data) {
      console.log(err.response.data)
    }
    console.log("getWatchingStreamCount  error ", err.message)
    return 0
  }
`
@RupamShaw
Copy link
Author

I hope its not axios issue

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

1 participant