Uploading picture but failed to get output


I got Pen to Print - Handwriting OCR API Documentation from Rapid API and it tested succssfully. But some coing need to be change when I want to use it on Node Red.

I use (javascript)fetch as my mode of coding.

const form = new FormData();
form.append("Session", "string");
form.append("srcImg", "photo_2021-09-16_18-49-42.jpg");

fetch("https://pen-to-print-handwriting-ocr.p.rapidapi.com/recognize/", {
"method": "POST",
"headers": {
"content-type": "multipart/form-data; boundary=---011000010111000001101001",
"x-rapidapi-host": "pen-to-print-handwriting-ocr.p.rapidapi.com",
"x-rapidapi-key": "eee39b0bfdmsh2a9df53d16d7303p156127jsne96465bf0c7d"
.then(response => {
.catch(err => {

The issue is :

  1. error shows "ReferenceError: FormData is not defined (line 1, col 14)" , maybe need some suggestion on how to take out the output (image) that I upload throught UI upload node.

I think something to do with line 1,2,3 and after that response how to respose to give output in text.

My nodes connection :

Screenshot 2021-09-16 201724

My UI OCR reader.

Picture will uplad and give out text .

These are link of my references :

-OCR reader API
Pen to Print - Handwriting OCR API Documentation (serendi) | RapidAPI

You can't* use fetch inside of a function node. Which is a client side thing. Function nodes run server side (in nodejs)

Use the HTTP request node instead of coding fetch in a function node.

* You could use node-fetch but there is no need.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.