Skip to content

Can't return htmlResponse for JS SDK #4

@ansbr

Description

@ansbr

Hello! Thanks for framework, it's great. But I have a problem with JS SDK,
In AssembleScript we have

import { util } from 'near-sdk-as'
...
function htmlResponse(text: string): Web4Response {
   return { contentType: 'text/html; charset=UTF-8', body: util.stringToBytes(text), status: 200 } as Web4Response;
}

But in JS SDK we haven't util, so I tried something like this:

function htmlResponse(text: string): Web4Response {
    return { contentType: 'text/html; charset=UTF-8', body: new TextEncoder().encode(text), status: 200 } as Web4Response;
}

But it not working...
Could you create example for JS SDK? It will be very helpful for all js developers).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions