Reputation: 554
I am building a library management system using MERN Stack, where the ISBN number is fetched from free Google Book API. But I am confused about how to fetch an API to my application.
Upvotes: 1
Views: 1180
Reputation: 6718
You can use fetch
API implemented by browsers or AJAX
for using with ReactJS (or any frontend code for that matter)
With nodejs
you can use pacakages like request, request-promise, node-fetch, axios
in similar fashion.
An example using request
library available for nodejs
request
.get('http://google.com/img.png' // api url)
.on('response', function(response) {
console.log(response.statusCode) // 200
console.log(response.headers['content-type']) // 'image/png'
// save the image somewhere, or render to webpage
})
.pipe(request.put('http://yoursite.com/img.png'))
Upvotes: 1