Home > Enterprise >  React Typescript API Type for Java byte[] image/png
React Typescript API Type for Java byte[] image/png

Time:11-18

I am converting this to a Typescript Service for our React web application. Below is the Original API in Java. What is the Typescript Response data type? Blob?

@GET
@Path("/{vendorId}/Photo}")
@Produces("image/png")
byte[] getVendorPhoto(@PathVariable long vendorId);

CodePudding user response:

By typed array

const idView = new Uint32Array(buffer, 0, 1);
const usernameView = new Uint8Array(buffer, 4, 16);
const amountDueView = new Float32Array(buffer, 20, 1);

CodePudding user response:

The JS equivalent of Java byte type is a Int8Array. Because the Java byte is a signed 8-bit integer.

const byteArray = new Int8Array(new ArrayBuffer(arrayOfInts));
  • Related