When receiving data from a web server, the data is always a string.
Parse the data with JSON.parse(), and the data becomes a JavaScript object.
Array as JSON
When using the JSON.parse() on a JSON derived from an array, the method will return a JavaScript array, instead of a JavaScript object.
Example
const text = '["Ford", "BMW", "Audi", "Fiat"]';
const myArr = JSON.parse(text);
When sending data to a web server, the data has to be a string.
Convert a JavaScript object into a string with JSON.stringify().
const promisesTest1 = new Promise((resolve,reject)=>{
if(true)
resolve('passed')
else
reject('failed')
})
const promisesTest2 = new Promise((resolve,reject)=>{
setTimeout(()=>{
if(true)
resolve({apires:{name:"gowtham"}})
else
reject('failed')
},2000)
})
Promise.all([promisesTest1,promisesTest2]).then((res)=>{
console.log('All passed',res)
})
promisesTest1.then((res)=>{
console.log(res)
}).catch((err)=>{
console.log(err)
})