Created
December 31, 2020 22:10
-
-
Save omizzy/5e275ce4c519b974704034336323c187 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jwt = require( 'jsonwebtoken' ); | |
const axios = require( 'axios' ); | |
const secret = 'API secret'; | |
const payload = { | |
aud: 'Environment ID', | |
iat: Date.now(), | |
} | |
const token = jwt.sign( payload, secret, { algorithm: 'HS256' } ); | |
axios( { | |
method: 'post', | |
url: '"API base URL"/convert', | |
data: { | |
html: "<p>I am a teapot</p>", | |
css: "p { color: red; }", | |
options: { | |
margin_top: "2cm" | |
} | |
}, | |
headers: { | |
'Authorization': token | |
} | |
} ).then( response => { | |
console.log( response ); | |
} ).catch( error => { | |
console.log( error ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment