Comments (5)
Sure, no worries, I was just wondering. Thanks for the help. 🙂
from mailjs.
If anyone is wondering, there is a method for this now. 27d8b95
from mailjs.
Hi,
There is currently no feature for this. But you can directly forward the token to the created instance.
const mailjs = new Mailjs();
mailjs.token = "MY_TOKEN";
This method will not give you the user ID and address so to solve this problem you will need a function to give the id and address information after issuing the token.
async function loginWithToken(token) {
const mailjs = new Mailjs();
mailjs.token = token;
const res = await mailjs.me();
// Throw the error message if the request failed.
if(!res.status) throw new Error(res.message);
mailjs.id = res.data.id;
mailjs.address = res.data.address;
return mailjs;
}
function loginSuccess(mailjs) {
// mailjs maintains an authorized instance.
}
loginWithToken("MY_TOKEN")
.then(loginSuccess)
.catch(console.error)
I hope this will work for you.
from mailjs.
Hi,
Yeah so this was my initial plan to set the token however as I mentioned, the token has a private type assigned to it, so you can't overwrite it. Not sure if this is a bug with the TypeScript typings, but this is what I get when I try to override the token. This is why I wasn't sure if it was possible or not.
from mailjs.
Yes, you are right.
I added TypeScript to the project later, I don't remember why I used it with private. Maybe I can add a new function.
But overriding TypeScript for that line might be a workaround.
// @ts-ignore:next-line
from mailjs.
Related Issues (12)
- Publish rpm package HOT 4
- Make eventsource.min.js really optional HOT 1
- Latest version does not work for browser HOT 1
- ReferenceError: fetch is not defined in Nodejs HOT 2
- expose response status code in IResult
- handle rate-limit errors internally
- Can't the same account be created again after the DELETE /accounts/{id} interface is invoked to delete the account? HOT 1
- Delete Multiple emails HOT 3
- Failed to execute 'fetch' on 'Window': Illegal invocation
- createOneAccount() types are not correct HOT 1
- CDNs do not include mailjs.min.js built for use in browser HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mailjs.