Strapi v4 REST API :GET image [closed] - javascript

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 10 months ago.
Improve this question
please I am working with the new strapi v4 and... In the old versions of strapi all I needed to do in order to get the image from my collection type was to get it like:
<img src={config.baseURL + product?.productImg?.formats?.thumbnail?.url} />
but when I try to do the same now, it gives me the url address, but the response says
{"data":null,"error":{"status":404,"name":"NotFoundError","message":"Not Found","details":{}}}
Any help?

with strapi v4 u need to manually populate your rest api with images otherwise it's restricted due to security reasons :
localhost:1337/api/posts?populate=*
then you will get images on your endpoint

I realised it. In my config file I had the baseURL as 'localhost:1337/api'. However for images, you must request without the '/api' so the request should be just 'localhost:1337' and then the image route.

Related

NodeJs Fetch & Axios not working in URL contain Cloudflare [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 days ago.
Improve this question
I use NodeJs to send request to API url which is contain Cloudflare using Fetch & axios package. but its not working. Anyone have idea about how to send API request through URL which is contain cloudflare? thank you very much
NodeJs use fetch & axios

How to use png response in axios get request in react [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
i send get request to a url and response is a object that contain a Png file and i just want to know how can i use this png in my react app ?
In general: Don't use axios in the first place. Just assign the URL to an image element:
<img src={your_url} alt={suitable_alt_text} />
This question is a little unclear. You need to state in what way you want to use this data and where you have made the request in your react component.Could you post the full file here and I can give a better answer of how you can do this?
From what I can see you could use this response and use the url returned from the object in the <img /> element by adding the key src={data.url} in the element, but I need see if you are setting state or however you use it to give you a fuller answer.

How should I call my internal API from JavaScript? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have an API in my app, how can I call the API in a JS script when I don't have a URL and I'm still in development?
Do not specify the domain name as part of the API's URL and deploy the JavaScript application to the same domain/port as the PHP API. You may have to do this anyway for security reasons (look up CORS).
So, if you call your API endpoint at /api/endpoint from your application deployed at /app, you will be independent of the domain, no matter if you are working locally
http://localhost:8080/app
http://localhost:8080/api/endpoint
, or in production
https://example.com/app
https://example.com/api/endpoint

Twitch.tv Api C# Get Streams [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to create a Twitch.tv app for desktop Pc. I have read that Twitch api use Json for the streams.
Can someone please explain me how I get the streams into a list? I plan to use C# get the list into a listbox but im stuck and cant continue because I dont know how to get what is available
Another way I was thinking is using Javascript but same problem can someone help me?
The github shows how you can get stream from twitch. First you send a request like shown on github "curl -H 'Accept: application/vnd.twitchtv.v2+json' -X GET https://api.twitch.tv/kraken/streams/test_channel" then you will get a JSON file (that contains all the information you need) as a response, you the read the file and use it in your application

RESTful Commit to Github file [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I've been looking for quite some time if it is even possible to do this.
I'd like to make a RESTful POST call with a javascript without the use of a server (node) to send a json object in the request body to update a json file in a github repo triggering a commit/push.
Yes, it's possible to do this using the Github API.
The URL must be something like that:
https://api.github.com/repos/{repositoryName}/contents/{path}
repositoryName is the repository where you want to put your file and path its path within this repository.
Regarding the authentication, you need to follow this link https://developer.github.com/v3/#authentication. I successfully tested with basic auth.
You need then to use an HTTP method PUT with content with the following structure:
{
"message": "a commit message",
"content": "bXkgbmV3IGZpbGUgY29udGVudHM="
}
The field content corresponds to the content of your file encoded with base 64.
Hope it helps.
Thierry

Categories

Resources