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

How to run axios in node js context with nw.js #8198

Closed
wanematou opened this issue Jul 22, 2024 · 1 comment
Closed

How to run axios in node js context with nw.js #8198

wanematou opened this issue Jul 22, 2024 · 1 comment
Labels

Comments

@wanematou
Copy link

Run axios in node js context with nw.js

I'm trying to read data like:

createIpBinding() {
            new Promise((resolve, reject)=>{
            const response= axios.put(`https://192.168.00.1:8383/rest/ip/hotspot/ip-binding`,
                    {
                            "mac-address": macAddress,
                            "type": byPassed,
                            
                    }, 
                    {
                             httpsAgent: new https.Agent({ rejectUnauthorized: false}),
                            auth: {
                            username: "admin",
                            password: "admin"
                            },
                            headers: {
                            'Content-Type': 'application/json',
                            }
                    },
            
            );
            console.log(response);
            if(response.data){
                    resolve(response)
            }else{
                    reject(response)
            }
            })
        },

but it sends me back self-signed certificate despite httpsAgent: new https.Agent({ rejectUnauthorized: false}).
So it's execute in node js context?

@bluthen
Copy link
Contributor

bluthen commented Jul 24, 2024

I usually do this:

index.html

<script>
delete window.require;
</script>

Somewhere else:

const node = {};
node.axios = nw.require('axios');

Make sure node-remote is set correctly for whatever you are trying to do:
https://nwjs.readthedocs.io/en/stable/References/Manifest Format/#node-remote

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

No branches or pull requests

3 participants