-
-
Save arun12209/a5a12d07d015c4039423b6cb909f1915 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const recordMetadata = { | |
name: 'name', | |
email: 'email', | |
website: 'url', | |
amount: 'currency', | |
phone: 'phoneNumber', | |
closeAt: 'dateInFuture', | |
}; | |
const ENDPOINT ='https://data-faker.herokuapp.com/collection'; //API endpoint | |
const POST_METHOD = 'POST'; //POST method | |
const CONTENT_TYPE = 'application/json; charset=utf-8'; | |
export default function fetchDataHelper({ amountOfRecords }) { | |
/* The global fetch() method starts the process of fetching a resource from the network, | |
returning a promise which is fulfilled once the response is available. | |
*/ | |
return fetch(ENDPOINT, { | |
method: POST_METHOD, | |
headers: { | |
'Content-Type': CONTENT_TYPE, | |
}, | |
body: JSON.stringify({ | |
amountOfRecords, | |
recordMetadata, | |
}), | |
}).then((response) => response.json()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment