I am trying to use the server/API of Nuxt 3 to call another API (ApiPlatform) which uses the JsonLd format. The request works well with JSON, but I can’t get a response in JsonLd. The server returns this 500 error, as shown below:
"<pre><span class="stack internal">at createError (./node_modules/h3/dist/index.mjs:79:15)</span>n<span class="stack">at ./.nuxt/dev/index.mjs:1163:12</span>n<span class="stack internal">at process.processTicksAndRejections (node:internal/process/task_queues:95:5)</span>n<span class="stack internal">at async Object.handler (./node_modules/h3/dist/index.mjs:1697:19)</span>n<span class="stack internal">at async Server.toNodeHandle (./node_modules/h3/dist/index.mjs:1907:7)</span></pre>"
Here is the request code in the Nuxt back-end server/API:
const data = await $fetch('http://shopgallery.local/print_formats?page=1', {
method: 'GET',
headers: {
accept: 'application/ld+json',
authorization: 'Bearer ' + token
}
});
Is it possible to use JsonLd in this type of server, or do I have to send the request directly through the front-end component? This solution works, but I don’t want to expose my authorization token in the browser console.
Using jsonLd format request through nuxt server api