skip to Main Content

javascript: Not sending array with fetch api

I am trying to send array with fetch api. but it goes null. javascript: const url = "/TMF/DownloadFolderFilesAsZip"; var data = { method: "POST", body: JSON.stringify({ folderFiles: foldersFiles }), headers: new Headers({ 'content-type': 'application/json' }) } fetch(url, data) .then(resp =>…

VIEW QUESTION

API Key Undefined in Axios – Reactjs

So I literally tried fetch and switch to axios to see what was wrong and still says my API key is undefined `import axios from "axios"; const apiKey = process.env.OPENAI_API_KEY; console.log(apiKey); axios .post( "https://api.openai.com/v1/chat/completions", { model: "gpt-3.5-turbo", messages: [{ role:…

VIEW QUESTION

Can't access json element using Fetch

I'm trying to fetch a json file and display its elements in a div. This is my json data : [ { "0":{ "host_id":"129230780", "host_names":"STK Homes", "host_since":"2017-05-07T12:45:49Z", "nb_listings":"2128", "langues":"['English']", "localisation":"Londres, Royaume-Uni", "is_superhost":"False", "is_viewer_profile_owner":"False", "reviews_count":"1228", "url":"https://fr.airbnb.ca/users/show/129230780" }, "1":{ "host_id":"121683635", "host_names":"Evolve", "host_since":"2017-03-20T16:26:31Z",…

VIEW QUESTION
Back To Top
Search