SWAPI - Star Wars

The Star Wars API

Go to site

Integrate the SWAPI - Star Wars API with the MySQL API

Setup the SWAPI - Star Wars API trigger to run a workflow which integrates with the MySQL API. Pipedream's integration platform allows you to integrate SWAPI - Star Wars and MySQL remarkably fast. Free for developers.

Connect SWAPI - Star Wars

import { axios } from "@pipedream/platform"
export default defineComponent({
  props: {
    swapi: {
      type: "app",
      app: "swapi",
    }
  },
  async run({steps, $}) {
    return await axios($, {
      url: `https://swapi.dev/api/films/1/`,
    })
  },
})

Connect MySQL

module.exports = defineComponent({
  props: {
    mysql: {
      type: "app",
      app: "mysql",
    }
  },
  async run({steps, $}) {
    const mysql = require('mysql2/promise');
    
    const { host, port, username, password, database } = this.mysql.$auth
    
    const connection = await mysql.createConnection({
      host,
      port,
      user: username,
      password,
      database,
    });
    
    const [rows, fields] = await connection.execute('SELECT NOW()');
    console.log(rows)
  },
})