# Uploading picture but failed to get output

**URL:** <https://discourse.nodered.org/t/uploading-picture-but-failed-to-get-output/51099>\
**Category:** General\
**Tags:** http-request\
**Created:** [16 September 2021 12:16 UTC](https://discourse.nodered.org/t/uploading-picture-but-failed-to-get-output/51099 "2021-09-16T12:16:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nurulh1909](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nurulh1909/32/39779_2.png) [@nurulh1909](https://discourse.nodered.org/u/nurulh1909)\
**Post date:** [16 September 2021 12:16 UTC](https://discourse.nodered.org/t/uploading-picture-but-failed-to-get-output/51099/1 "2021-09-16T12:16:26Z")

</div>

Hi,

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/](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](http://pen-to-print-handwriting-ocr.p.rapidapi.com)",  
"x-rapidapi-key": "eee39b0bfdmsh2a9df53d16d7303p156127jsne96465bf0c7d"  
}  
})  
.then(response =\> {  
console.log(response);  
})  
.catch(err =\> {  
console.error(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.

 ![Screenshot 2021-09-16 201057](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/4/d44eb1bd2aa52871ce8abd4c96068d006ec2bf00.jpeg)

My nodes connection :

![Screenshot 2021-09-16 201724](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/d/0d28dc54fb8496c167a8c7b76afb79479401bb0e.jpeg)

My UI OCR reader.

Picture will uplad and give out text .

 ![Screenshot 2021-09-16 201223](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/8/6826bfc223a22d9f984e640a18af2fb789a38da7.jpeg)

These are link of my references :

- upload UI  
[node-red-contrib-ui-upload (node) - Node-RED (nodered.org)](https://flows.nodered.org/node/node-red-contrib-ui-upload)

-OCR reader API  
[Pen to Print - Handwriting OCR API Documentation (serendi) | RapidAPI](https://rapidapi.com/serendi/api/pen-to-print-handwriting-ocr/)

 ![Screenshot 2021-09-16 200921](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/7/27d109a0102ca6335ae977785b55b992985613ea.jpeg)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 September 2021 13:59 UTC](https://discourse.nodered.org/t/uploading-picture-but-failed-to-get-output/51099/2 "2021-09-16T13:59:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [15 November 2021 14:00 UTC](https://discourse.nodered.org/t/uploading-picture-but-failed-to-get-output/51099/3 "2021-11-15T14:00:20Z")

</div>

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