Category : request

I need to know why my post request isn’t creating a new JSON file. I am using a JS POST fetch request. The code is below. //Assume all the variables are defined fetch(lowercaseUsernameStr+’_profile_data.json’, { method: ‘POST’, headers: { ‘Content-Type’: ‘application/json’, }, body: { “publicData”: { “username”: usernameStr, “userDescription”: userDescription, “favoriteGameData”: { “favoriteGameCategory”: favoriteGameCategoryStr, “favoriteGameNum”: favoriteGameNum ..

Read more

I want to get information from the http request and send it to the frontend via the path ‘/ get’. I combined these 2 functions and it works but I don’t think it is correct: const https = require(‘https’); router.get(‘/get’, (req, res) => { https.get(‘https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY’, (resp) => { let data = ”; resp.on(‘data’, (chunk) => ..

Read more

I have an app on React.js and PHP backend. All fetch requests work until the Request Payload is added to them. I am specifically concerned about this request: fetch(‘https://interluoja-api.000webhostapp.com/api/Login’, { method: "POST", mode: ‘cors’, headers: { ‘Content-Type’: ‘application/json’ }, body: JSON.stringify({ ‘login’: event.target[0].value, ‘password’: event.target[1].value }) }) Such a request in any case returns the ..

Read more