How do I return an xml http response from my worker?

How do I return an xml http response from my worker?

I have a Worker that is Fetching a JSON response from Url.
This is then transformed to XML using a function.

I need to return the XML in the main response but do not know how to get this working.

Process:

  1. 3rdParty accesses my Worker URL.
  2. Worker Fetches data from another URL.
  3. Worker transforms JSON to XML.
    4 Worker returns XML response to 3rdParty. <-- this is not working. How to fix?

Regards,
Darren

You simply pass the XML string to a Response object and you are good to go.

Response is covered at Response · Cloudflare Workers docs

But overall that is a question rather for StackOverflow than the forum here :slight_smile:

1 Like

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