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

Document usage of agent #1701

Open
char0n opened this issue Sep 1, 2020 · 1 comment
Open

Document usage of agent #1701

char0n opened this issue Sep 1, 2020 · 1 comment

Comments

@char0n
Copy link
Member

char0n commented Sep 1, 2020

More information in this comment. Let's document the fact that our http interface consumes another options from fetch interface in more generic way and add a concrete example about using agent as described in attached comment.

@charlescoult-boeing
Copy link

Was this ever resolved? I'm trying to use a custom https agent that supplies a cert and the only way I've been able to get it working is through a requestInterceptor that uses Axios:

            requestInterceptor: (request) => {
                // console.log('adding agent')
                request.agent = httpsAgent
                // request.httpsAgent = httpsAgent
                // request.data = body
                request.userFetch = async (url, req) => {
                    // console.log(`fetching`)
                    // return fetch(url, { ...req, agent: agent })

                    const axiosRequest = { ...req, data: req.body, httpsAgent: request.agent }
                    const axiosResponse = await axios(axiosRequest)
                    debugger

                    /* not ideal but axios already parses the JSON response data
                     * and SwaggerClient expects it to still be in text form so
                     * we need to stringify it again */
                    return new Response(JSON.stringify(axiosResponse.data), {
                        status: axiosResponse.status,
                        headers: axiosResponse.headers,
                    })
                }
                return request
            },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants