Published

Bone Age API client (NodeJS).

Bone Age API client written in NODEJS, by Alan
Turing

"Bone Age API client written in NODEJS, cubism art" by Alan Turing (DALL-E)

Inline Highlighting

Bone Age API client (NodeJS)

Javascript client

client.js
const fetch = require('node-fetch');

const AZYRI_URI = process.env.AZYRI_URI;

const getBoneage = async (data) => {
	try {
    const response = await fetch(AZYRI_URI, {
			method: 'POST',
			headers: {
				'Content-Type': 'application/json',
			},
			body: JSON.stringify(data),
		});
		return await response.json();
	} catch(err) {
		return {
			payload: {},
			success: false,
			errorMessage: new Error(err).message,
		};
	}
};

exports.getBoneage = getBoneage

Bone Age client

client.js
require('dotenv').config();
const fs = require('fs');
const FormData = require('form-data');

const client = require('./client')

const AZYRI_TOKEN = process.env.AZYRI_TOKEN;
const args = process.argv.slice(2);

const action = async () => {
  let gender = args[0]
  let xray = args[1]
  var form = new FormData();
  console.log("gender=" + gender)
  console.log("xray=" + xray)
  //form.append('file', fs.createReadStream(xray));
  form.append('gender', gender);
  const result = await client.getBoneage({token: AZYRI_TOKEN, gender: gender});
  console.log(JSON.stringify(result))
}

action();

GitHub code

GitHub code