1

How to make http request from parse cloud server(back4app) to another server, here i am making request to fake json api https://jsonplaceholder.typicode.com/todos/1

main.js

Parse.Cloud.define("hello", async (request) => {
return Parse.Cloud.httpRequest({
    url: 'https://jsonplaceholder.typicode.com/todos/1',
    followRedirects: true,
    method: 'POST',
    headers: {
        'Content-Type': 'application/json;charset=utf-8'
      }
}).then(function(response){
     console.log(response.text)
    //return response.text;
     //return response.success(response.text)
    //resData=100;
    return 100; //i am not even returning the response,i am returning a just a const
    
},function(httpResponse) {
    console.error('Request failed with response code ' + httpResponse.status);
})

});

App.js

const cloudFunction=async()=>{
const someVar=10
Parse.Cloud.run('hello').then((response)=>{
console.log(response)
}).catch((error)=>{
console.log(JSON.stringify(error))
})

}

can some body help,thank you good people of stackoverflow

bikashamit
  • 11
  • 4

0 Answers0