Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A TypeScript snippet for making external authenticated web API calls in Electron
import electron from 'electron';
function performExternalRequest() {
const cookieJar = electron.remote.session.defaultSession.cookies;
const cookie = {
url: 'https://youdomain.com',
name: 'your-cookie-name',
value: 'your-cookie-value'
};
cookieJar.set(cookie)
.then(() => {
fetch('https://your-api.domain/endpoint', {
credentials: 'include'
})
.then((response) => {
console.log(response);
})
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment