Browser example – step 1: create job | School Menu

node v12.22.12
version: 1.0.0
endpointsharetweet
const { Client } = require('@automationcloud/client'); const express = require("@runkit/runkit/express-endpoint/1.0.0"); const app = express(exports); app.use(function(req, res, next) { res.header('Access-Control-Allow-Origin', '*'); res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'); next(); }); app.post("/", async (req, res) => { const serviceId = '691030cf-57ae-47bc-b863-75e9a12f973e'; // Create Client instance const client = new Client({ serviceId, auth: process.env.SECRET_KEY // That's the secret key of the Application }); try { // Create Job. const job = await client.createJob(); // Obtain Job specific accessToken to use in the browser const accessToken = await job.getAccessToken(); res.send({ jobId: job.jobId, serviceId, accessToken }); } catch(error) { res.send({ error }); } });
Loading…

no comments

    sign in to comment